1

I build an android app with Android Studio with Java and I want to get the mac address from the phone limit user any action do and somethings else who can help me? my code is this but didnt work

 private void getmacadres() { String macAddress = android.provider.Settings.Secure.getString(this.getApplicationContext().getContentResolver(), "android_id"); Toast.makeText(G.Context, macAddress, Toast.LENGTH_LONG).show(); } 
2
  • 1
    Is you add in androidManifest : <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> Commented Dec 23, 2019 at 7:14
  • What did you mean by "limit user any action do and somethings"? Commented Dec 23, 2019 at 17:39

2 Answers 2

3

add this permission to your manifest file:

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> 

and use this:

WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); WifiInfo wInfo = wifiManager.getConnectionInfo(); String macAddress = wInfo.getMacAddress(); 
Sign up to request clarification or add additional context in comments.

Comments

-1

I have solved this problem by using this

 private String deviceId() { return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.