Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

different Settings.Secure.ANDROID_ID for same device on Different machine apk

Tags:

android

I am getting AndroidId using code String android_id = Settings.Secure.getString(MyApplication.getContext().getContentResolver(), Settings.Secure.ANDROID_ID);

if i run this code on different machine then I am getting different android_id for same device. Why is it so?

Thanks in advance

like image 311
PPD Avatar asked Dec 03 '25 13:12

PPD


2 Answers

See the Android 8.0 Behavior Changes and documentation of ANDROID_ID.

For apps installed on a device running Android 8.0, the value of ANDROID_ID is now scoped per app-signing key, as well as per user. The value of ANDROID_ID is unique for each combination of the app-signing key, user, and device. As a result, apps with different signing keys running on the same device no longer see the same Android ID (even for the same user).

like image 94
Yong Avatar answered Dec 05 '25 06:12

Yong


I would strongly recomment to read this post https://developer.android.com/training/articles/user-data-ids

It is not good practice to get unique device Id.

If you still want to do it try

String android_id = Settings.Secure.getString(getApplicationContext().getContentResolver(),
                Settings.Secure.ANDROID_ID);

also dont forget that it might be null

like image 23
Antonis Radz Avatar answered Dec 05 '25 05:12

Antonis Radz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!