12

How do we get Unique Device ID from the Android Tablets (Android 3.0 SDK HoneyComb)?

I have also found that we can get Android Device ID which is unique by using: String deviceId = Settings.System.getString(getContentResolver(), Settings.System.ANDROID_ID);

But Here its written that Although, it is not guaranteed that the Android ID will be an unique identifier..

I have also gone through the some SO Questions:

  1. Is there a unique Android device ID?
  2. How to find serial number of Android device?

And also referred this article: http://android-developers.blogspot.com/2011/03/identifying-app-installations.html.

But i am confused how do we get/have Unique Device ID from the Android Tablet type of Device?

Community
  • 1
  • 1
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295

2 Answers2

21

I know this question is old but it might through off somebody that finds it since android ID has no guarantee to work, it might even be null in some cases or easily changed on rooted phones.

What I did was combine the Android ID with the WiFi MAC address in a method that generates a UUID:

private void generateDeviceId() {
    final String macAddr, androidId;

    WifiManager wifiMan = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
    WifiInfo wifiInf = wifiMan.getConnectionInfo();

    macAddr = wifiInf.getMacAddress();
    androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);

    UUID deviceUuid = new UUID(androidId.hashCode(), macAddr.hashCode());

    // Maybe save this: deviceUuid.toString()); to the preferences.
}

Dont forget to add the permissions to the AndroidManifest.

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

Good luck!

Lisandro
  • 10,543
  • 1
  • 24
  • 29
5

Starting with Android 2.2, ANDROID_ID is pretty much guaranteed to be unique.

There was an article about that on the Android developer blog very recently.

EboMike
  • 76,846
  • 14
  • 164
  • 167
  • Thanx for the support, is it feasible to use ANDROID_ID for Android 3.0 Honeycomb as i am developing application using 3.0? – Paresh Mayani Apr 06 '11 at 07:01
  • Yes. Judging by that blog, Honeycomb has a unique ANDROID_ID. – EboMike Apr 06 '11 at 07:35
  • hey dear, i have also listed earlier the same link: http://android-developers.blogspot.com/2011/03/identifying-app-installations.html. I have gone through but i was confused. So asked a question here. – Paresh Mayani Apr 06 '11 at 08:39
  • @PM: The key of the blog entry is that ANDROID_ID is producting a reliably unique number starting with Android 2.2. I suppose you are targeting Honeycomb? Then you are good, Honeycomb contains all the features of 2.2. – EboMike Apr 06 '11 at 09:14
  • ya i am developing an application especially using HoneyComb version. Thanx for your kind support. – Paresh Mayani Apr 06 '11 at 13:12
  • 1
    Actually, in Android 2.2 there is a [bug](http://code.google.com/p/android/issues/detail?id=10639) which makes it possible that different devices have the same Android ID (see also [here](http://groups.google.com/group/android-developers/browse_thread/thread/53898e508fab44f6/3aca6310acc63915) for more information). This bug was fixed in Android 2.3. – Piotr Jul 25 '11 at 11:43