Alternative way removes security warning when using ANDROID_ID and how to get the device id?

拥有回忆 提交于 2020-01-23 17:12:46

问题


public static String getDeviceID(Context mContext) {

    String deviceId = Settings.Secure.getString(mContext.getContentResolver(),
            Settings.Secure.ANDROID_ID);
    return deviceId;
}

This shows a security warning,

"Using 'getString' to get device identifiers is not recommended "

How to resolve this warning?


回答1:


You can't really "resolve" this warning.

Lint is trying to move you from android ID to advertising id if possible, because for most use cases it's better for user. If you want to disable the warning @SuppressLint("HardwareIds") takes care of that.



来源:https://stackoverflow.com/questions/46321611/alternative-way-removes-security-warning-when-using-android-id-and-how-to-get-th

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!