Is Secure.Android_Id Unique for Each Device

Is Secure.ANDROID_ID unique for each device?

Check into this thread,. However you should be careful as it's documented as "can change upon factory reset". Use at your own risk, and it can be easily changed on a rooted phone. Also it appears as if some manufacturers have had issues with their phones having duplicate numbers thread. Depending on what your trying to do, I probably wouldnt use this as a UID.

Settings.Secure.ANDROID_ID is not unique, how to solve?

In general this is a serious problem with Android - it seems the Android ID is the best option BUT as you note several significant vendors have made a mess of the implementation.

Confronted by a similar requirement I have used a hash of these values:

  • Phone number/SIM card number (if available or just use zeros)
  • Android ID
  • Mac Address (if available or just use zeros)

In my limited experience (several hundred devices in use) this combination has been good enough to achieve the uniqueness you need.

Update 2017
from Android 6 the Mac address returns a constant value for security reasons - however in almost all newer implementations of android the android ID seems to be reliably unique so unless you are targeting older versions you would have no motive to use this technique.

Settings.Secure.ANDROID_ID always the same on each device

You can read this here http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID

Android ID:
A 64-bit number (as a hex string) that is randomly generated on the device's first boot and should remain constant for the lifetime of the device. (The value may change if a factory reset is performed on the device.)

But on the Androids Developers Blog they write about your problem and show you a solution.
http://android-developers.blogspot.in/2011/03/identifying-app-installations.html

ANDROID_ID seems a good choice for a unique device identifier. There are downsides: First, it is not 100% reliable on releases of Android prior to 2.2 (“Froyo”). Also, there has been at least one widely-observed bug in a popular handset from a major manufacturer, where every instance has the same ANDROID_ID.

Android_ID in Android O

1) Imagine your app has the id abc when installed on an N device. Now when the device gets updated to O the device id returned to you will continue to be abc. However if the user uninstalls and reinstalls the app after upgrading to O, ANDROID_ID will change to some other value.

On the other hand if the app was installed on an O device and is then uninstalled and reinstalled the ANDROID_ID will remain the same.

2) It means that as long as the package name and signature remain the same the value of ANDROID_ID will remain the same. It will also remain the same if your app gets updated on an O device and the signature changes.

Essentially, android will now use the package name/ signature to generate the unique identifier on O.

Is there any unique Id for android devices apart from Settings.Secure.ANDROID_ID?

You should read Best practices for unique identifiers and THIS topic, but in short: there is no reliable variable/value in system across different manufacturers and versions, definitely not for reset case. If you want persist, unique identifier for your app then use UUID.randomUUID().toString() and store this value in e.g. SharedPreferences. It will persist as long as your app will be installed.



Related Topics



Leave a reply



Submit