Durai Amuthan.H
Durai Amuthan.H

Reputation: 32270

Perfect unique_id for device except IMEI,Android_ID,WLAN Mac and Bluetooth address

Objective:

I am looking for a way to find out a unique_id for android device.

Background:

I will use the Id in login request payload and as my app is license based service app the Id should not change under normal circumstances.

Existing Approaches:

In iOS there are some unique id solutions for iOS such as CFUUID or identifierForVendor coupled with Keychain,Advertising Identifier etc.. that can do this job upto the expectation.

But in Android all the options that I know seems to have hole in it.

IMEI:

TelephonyManager TelephonyMgr = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 
String m_deviceId = TelephonyMgr.getDeviceId();

Drawbacks

It is sim card dependent so

Android_ID:

  String m_androidId = Secure.getString(getContentResolver(), Secure.ANDROID_ID);

Drawbacks

The WLAN MAC Address

WifiManager m_wm = (WifiManager)getSystemService(Context.WIFI_SERVICE); 
String m_wlanMacAdd = m_wm.getConnectionInfo().getMacAddress();

Drawbacks

Bluetooth Address:

   BluetoothAdapter m_BluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 
   String m_bluetoothAdd = m_BluetoothAdapter.getAddress();

Drawbacks:

Possible solutions:

There are two approaches that I think to solve this problem

Any help is appreciated !

Upvotes: 14

Views: 6913

Answers (3)

Durai Amuthan.H
Durai Amuthan.H

Reputation: 32270

I have chosen to use Android_ID since It's not dependent on any hardware.

Build.SERIAL also dependent on availability of telephony that is in wifi only devices this Build.SERIAL won't work.

I have explained how other approaches are dependent upon the hardware availability in the question itself.

Upvotes: 7

Mikhail
Mikhail

Reputation: 71

I think, you could use device serial ID (hardware serial number, not android id). You could seen it in device settings. In your code, you could get it by Build.SERIAL.

Upvotes: 1

Per Christian Henden
Per Christian Henden

Reputation: 1585

There is no such ID available on Android. You can generate your own, for example a random UUID and connect it to the user's account. This is what Kindle, Audible and other applications do to identify devices in a non-privacy-intrusive way.

Consider Google Analytics Mobile if you want to "track your users", http://www.google.com/analytics/mobile/

If you want to get closer to tracking a device you can combine the IDs above together in a hash-function. Bluetooth + wifi + android serial, and if any of them are null, you put a 0 in the hash, e.g. if there is no wifi mac addr. As you point out, you aren't guaranteed the id won't change. Unless the user is running a custom ROM, I would expect this computed ID to stay constant, though.

Upvotes: 1

Related Questions