Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Tablet - Get Unique Device ID

Tags:

android

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?

like image 335
Paresh Mayani Avatar asked Apr 06 '11 06:04

Paresh Mayani


People also ask

How do I find my unique device ID Android?

TelephonyManager telephonyManager;telephonyManager = (TelephonyManager) getSystemService(Context. * getDeviceId() returns the unique device ID. * For example,the IMEI for GSM and the MEID or ESN for CDMA phones.

How do I find my unique device ID?

Method 1: Find Android device ID using dial pad codeOpen your phone's dial pad, usually named “Phone” in the apps drawer. 2. Here dial this code *#*#8255#*#*. As soon as you will enter the last digit, Gtalk Service Monitor will open up and show your Android device ID along with your email.

Does Android have device ID?

On Android, the device ID is the Android Advertising ID (AAID). Users are able to access their AAID within the settings menu under 'Google - Ads,' as well as reset the ID, and opt-out of ad personalization.


2 Answers

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!

like image 73
Lisandro Avatar answered Nov 01 '22 12:11

Lisandro


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.

like image 5
EboMike Avatar answered Nov 01 '22 11:11

EboMike