Android_ID
IMEI
广告 ID
这三个其实都不靠谱:
Android_ID 会存在重置或者失效的问题( There are downsides: First, it is not 100% reliable on releases of Android prior to 2.2 (“ Froyo ”). Also, there has been at least one widely-observed bug in a popular handset from a major manufacturer, where every instance has the same ANDROID_ID.)
IMEI 的问题更多:
1.需要“电话”权限,这个对一些用户而言,还是比较敏感的;
2.IMEI 在双卡双待手机上,读取两次,可能返回不一样的值(当然这个也可以读取一次后,存到 SharedPreference 里面,下次优先从 SP 读取就好);
3.IMEI 在部分设备上获取不到;
广告 ID:
这个就涉及另外一个问题:Google Play 要求使用这个时,要明确告知用户隐私政策,我们就曾因为引入第三方 SDK 中带了这个,而被 Google Play 直接下架,邮件内容见:
-----------------
After review, 钱迹-记账小能手, com.mutangtech.qianji, has been removed from Google Play due to a policy violation. This app won ’ t be available to users until you submit a compliant update.
Issue: Violation of Usage of Android Advertising ID policy and section 4.8 of the Developer Distribution Agreement
Google Play requires developers to provide a valid privacy policy when the app requests or handles sensitive user or device information.
-----------------
所以,如果想做到很靠谱的话,建议自己生成,然后自己持久化,可以参考 Google 官方博客
https://android-developers.googleblog.com/2011/03/identifying-app-installations.html问题是,如何持久化?
——写在 SD 卡上,这样 App 卸载重装也在。
唯一注意的就是如何避免被一些垃圾清理软件清除?
——多写几个,然后注意将存储的文件隐藏