简体   繁体   中英

Android device id doesn't match on Physical Device & Emulator

I found an application & they are using Device Identity as user login. After uninstall & install its showing same DeviceID. When I test this app on my android device. The device identity doesn't match with this String.

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

But when I tried this on android emulator string matched with that app device ID. But in my physical Device....

Showing on that app: 93edad60438f8004

Getting String Device ID: 5f1cf6393c37ae96

How can I get device ID as that application?

That App on Emulator Emulator Device ID

As of Android 26, every app on the device gets told a different Android ID for privacy reasons. This prevents companies from being able to share data on a user without his permission by just correlating the device id.

Also, a device id should NEVER be used as login credentials. I can get a version of Android that allows me to claim whatever id I want on an emulator with a quick recompile of AOSP. It can be spoofed way too easily. If you need to be able to log in a device, use a randomly generated key from your server and encrypt it with a key stored in the keystore. Do not count on an hardware identifier. They can be spoofed, and just as importantly you can't revoke them without breaking the user's ability to use your app. With a randomly generated token you can invalidate it server side and the user just has to log in again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM