简体   繁体   English

Android 设备 ID 在物理设备和模拟器上不匹配

[英]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.卸载并安装后显示相同的 DeviceID。 When I test this app on my android device.当我在我的 android 设备上测试这个应用程序时。 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.但是当我在与该应用程序设备 ID 匹配的 android 模拟器字符串上尝试此操作时。 But in my physical Device....但是在我的物理设备中......

Showing on that app: 93edad60438f8004在该应用程序上显示: 93edad60438f8004

Getting String Device ID: 5f1cf6393c37ae96获取字符串设备 ID: 5f1cf6393c37ae96

How can I get device ID as that application?如何获取该应用程序的设备 ID?

That App on Emulator Emulator Device ID模拟器上的那个 App模拟器设备 ID

As of Android 26, every app on the device gets told a different Android ID for privacy reasons.截至 Android 26,出于隐私原因,设备上的每个应用程序都会被告知不同的 Android ID。 This prevents companies from being able to share data on a user without his permission by just correlating the device id.这可以防止公司仅通过关联设备 ID 就可以在未经用户许可的情况下共享用户数据。

Also, a device id should NEVER be used as login credentials.此外,设备 ID 永远不应用作登录凭据。 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.我可以获得一个版本 Android,它允许我通过快速重新编译 AOSP 在模拟器上声明我想要的任何 ID。 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.使用随机生成的令牌,您可以使其在服务器端无效,用户只需重新登录即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有react-native的Android应用程序可以在模拟器上运行,但不能在物理设备上运行 - Android app with react-native works on emulator but doesn't on physical device Flutter 应用程序在 android 工作室模拟器上完美运行,但 go 无法通过物理设备上的加载屏幕 - Flutter app runs perfectly on android studio emulator but doesn't go past the loading screen on physical device Flutter 应用程序在 Android 模拟器上运行,但不在物理设备上(OnePlus 7T) - Flutter app is running on Android Emulator but not on Physical Device (OnePlus 7T) 将 android 仿真器连接为物理 android 设备 - connecting android emulator as a physical android device 仅在物理设备而非模拟器上运行 Android 应用 - Run Android app Only on Physical Device not Emulator 尝试用物理设备替换模拟器(Android Studio) - Tried to replace an emulator with a physical device (Android Studio) 通知显示在 android 仿真器中,但不在物理设备上 - Notification shows up in android emulator but not on physical device 在Android模拟器中调试物理USB设备 - Debugging physical USB Device in Android Emulator ImageButton在模拟器或物理设备上的Android Studio上不可见 - ImageButton not visible on Android Studio on Emulator or physical device 将 Wear OS 模拟器与物理 android 设备连接 - Connecting Wear OS emulator with a physical android device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM