4

We use the below code to get a unique ID:

String id = Settings.Secure.getString(mContext.getContentResolver(),
                 Settings.Secure.ANDROID_ID);

In the Android O changes guide we can see the below points:

Android O makes the following privacy-related changes to the platform. https://developer.android.com/preview/behavior-changes.html

The platform now handles identifiers differently.
Values of ANDROID_ID are now scoped per-app instead of per-user. The value of ANDROID_ID is unique for each combination of application package name, signature, user, and device. Two apps running on the same device no longer see the same Android ID, and so cannot correlate.

The value of ANDROID_ID does not change on package uninstall or reinstall, as long as the package name and signing key are the same.

The value of ANDROID_ID does not change if the package signing key changes due to an update.

For apps that were installed prior to the OTA, the value of ANDROID_ID remains the same unless uninstalled and then reinstalled.

If you wish to continue using Android ID for device-bound free trial protection, you can do so. Make sure that the package name and signature match.

For a simple, standard system to monetize apps, use Advertising ID. Advertising ID is a unique, user-resettable ID for advertising, provided by Google Play services.

My understanding of the above is that now the Android_ID going forward will be app bound rather than device bound. However I am confused about the below point:

For apps that were installed prior to the OTA, the value of ANDROID_ID remains the same unless uninstalled and then reinstalled. If you wish to continue using Android ID for device-bound free trial protection, you can do so. Make sure that the package name and signature match.

1) What does this mean? Unless my app is reinstalled it will continue having the legacy android_id, even if we send an update?

2) If you wish to continue using Android ID for device-bound free trial protection, you can do so. Make sure that the package name and signature match.: what does this mean?

Sid
  • 1,224
  • 3
  • 23
  • 48

2 Answers2

6

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.

ashkhn
  • 1,642
  • 1
  • 13
  • 18
  • 1 is now clear, regarding 2: If my package name and signature remains the same, then even if the app is uninstalled and reinstalled, the Android_ID will be the same?, or will it change? – Sid May 03 '17 at 09:22
  • Yes the same explanation as 1) applies here. If both actions occur on O then it will remain the same. If the first happens on – ashkhn May 03 '17 at 09:26
  • Sorry can you please explain : "If both actions occur on O then it will remain the same. If the first happens on – Sid May 03 '17 at 09:48
  • Also if the package name/ signature are constant than even an uninstall and re install will not change the android_id. – Sid May 03 '17 at 09:50
  • I meant that if the uninstall (1st action) occurs on a device running N or earlier and reinstall (2nd action) occurs when the device is running O the `ANDROID_ID` will change. – ashkhn May 03 '17 at 10:13
  • Hi guys, thanks for explanation. I have question - can ANDROID_ID be NULL? – svarog Feb 19 '18 at 14:48
1

The android documentation is not explicit about the ANDROID_ID values for applications with different package names but shared User ID value and signed with same key. The tests on Nexus 5, Android O Beta 3 show the value of Android ID for 2 applications is same in this case also.