PPD
PPD

Reputation: 5890

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

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

Upvotes: 3

Views: 6030

Answers (3)

Yong
Yong

Reputation: 1978

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).

Upvotes: 5

prashant17
prashant17

Reputation: 1550

Assuming you are talking about debug builds, It may be because you have different debug (Default) keystore.

Upvotes: 0

Antonis Radz
Antonis Radz

Reputation: 3097

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

Upvotes: 1

Related Questions