19

Currently, I am using MAC address as the identifier for an Android device.

WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wInfo = wifiManager.getConnectionInfo();
String mac = wInfo.getMacAddress();

However, I found the mac is empty for some users' devices. I am a little confused why it could be empty.

If you could figure out the reason, that's the best!

Otherwise, could you provide an alternative for identifying an Android device?

JackWM
  • 10,085
  • 22
  • 65
  • 92

2 Answers2

13

You can identify any android mobile uniquely on basis of imei.

TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.getDeviceId();

Add the permission into your AndroidManifest.xml:

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

In emulator, you'll probably get a like a 0000... value. Check it on device to get device id.

Ajay S
  • 48,003
  • 27
  • 91
  • 111
7

Your best bet with finding something unique about the Android device would be to access its serial number. There are several other posts on how to do this, but the most-viewed one is here:

How to find serial number of Android device?

Community
  • 1
  • 1
Phil
  • 35,852
  • 23
  • 123
  • 164