Right now i am trying to get mac address for tablets and smartphone in android.

I have tried with the below code.

TelephonyManager tm =   (TelephonyManager)Current_activity_name.this.getSystemService(Context.TELEPHONY_SERVICE); 
String str_macid = tm.getDeviceId();

this code is working only for smartphone but not for tablets.Why?

Suggestions please..

Thanks for your precious time!..

有帮助吗?

解决方案

If you want to get the MAC address of the WiFi modem you first need a permission

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

Next

WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
String macAddress = wifiManager.getConnectionInfo().getMacAddress();

This works if a WiFi connection currently exists.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top