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?

11
  • Why you want to do this? Commented Feb 15, 2013 at 17:01
  • @iTech it's used for storing per user's data in a database. Commented Feb 15, 2013 at 17:02
  • What about getting the user android account instead? i.e. email It is more stable, if the use sold his/her phone and got a new one, you will still be able to identify Commented Feb 15, 2013 at 17:02
  • @iTech how to get that programmatically? How about the user doesn't have an email account or never log in one? Commented Feb 15, 2013 at 17:04
  • How do you want to store these data in sql. Can you explain a little bit more so we can give you better answer? Commented Feb 15, 2013 at 17:04

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Devices that are not phones will not have a unique IMEI number.
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?

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.