Seb*_*ine 11 android identifier kotlin
根据谷歌的说法,在没有一些先决条件的情况下,Android 10 系统上不应访问 ANDROID_ID(也称为 SSAID)(请参阅:https : //developer.android.com/about/versions/10/privacy/changes)
• If your app targets Android 10 or higher, a SecurityException occurs.
• If your app targets Android 9 (API level 28) or lower, the method
returns null or placeholder data if the app has the READ_PHONE_STATE
permission. Otherwise, a SecurityException occurs.
Run Code Online (Sandbox Code Playgroud)
我的问题是,我仍然可以在没有上述任何先决条件的情况下访问 ANDROID_ID。
我创建了一个目标平台为 Android 10 API 级别 29 的 Kotlin 项目。
在这个项目中,我运行了以下代码:
• If your app targets Android 10 or higher, a SecurityException occurs.
• If your app targets Android 9 (API level 28) or lower, the method
returns null or placeholder data if the app has the READ_PHONE_STATE
permission. Otherwise, a SecurityException occurs.
Run Code Online (Sandbox Code Playgroud)
结果是,ANDROID_ID 被毫无问题地写入 logcat。该值不是虚拟值,而是实际的 ANDROID_ID。这已经在模拟器和真实设备(Pixel 2)上进行了测试。
也许为时已晚,但根据 android O android developer's blog 中的这篇文章
| 归档时间: |
|
| 查看次数: |
4850 次 |
| 最近记录: |