How to get a unique device identifier in Android?

How to get a unique device identifier in Android, which cannot be changed when the phone is reset or OS updates?

+69
android
Jun 01 '13 at 5:38
source share
4 answers

You are checking this blog from the link below.

http://android-developers.blogspot.in/2011/03/identifying-app-installations.html

ANDROID_ID

import android.provider.Settings.Secure; private String android_id = Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID); 

Above link is @ Is there a unique identifier for an Android device?

In particular, Settings.Secure.ANDROID_ID. This is a 64-bit amount that is generated and saved the first time the device boots. When erasing the device, reset .

ANDROID_ID seems like a good choice for a unique device identifier . There are drawbacks: firstly, it is not 100% reliable in Android releases prior to 2.2 ("Froyo"). In addition, at least one well-known mistake in a popular phone from a major manufacturer, where each instance has the same ANDROID_ID.

The solution below is not a good one when you wait for the device’s wet wipes (“Factory reset”), and thus you can make an unpleasant mistake when one of your customers wipes its device and transfers it to another person .

You get the imei device number using below

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

http://developer.android.com/reference/android/telephony/TelephonyManager.html#getDeviceId%28%29

Add this manifest

 <uses-permission android:name="android.permission.READ_PHONE_STATE"/> 
+116
Jun 01 '13 at 5:39
source share

I use the following code to get the android id.

 String android_id = Secure.getString(this.getContentResolver(), Secure.ANDROID_ID); Log.d("Android","Android ID : "+android_id); 

enter image description here

+17
Jun 01 '13 at 6:03
source share

Read this official Google developer blog post: http://android-developers.blogspot.be/2011/03/identifying-app-installations.html

Conclusion For the vast majority of applications, this is a requirement to identify a particular installation, not a physical device. Fortunately, this is easy to do.

There are many good reasons to avoid trying to identify a specific device. For those who want to try, the best approach is probably to use ANDROID_ID on something reasonably modern, with some backup heuristics for legacy devices

.

+1
Jun 01 '13 at 5:59 on
source share

We can easily get the device ID using String id = android.os.Build.ID;

-23
Jun 01 '13 at 5:59 on
source share



All Articles