Build.SERIAL 自 API 26 起已弃用:Android 8.0 Oreo
Build.SERIAL is deprecated as of API 26: Android 8.0 Oreo
我刚刚将我的应用程序更新为 API 26,我正在尝试检索设备的序列号,但我发现 Build.SERIAL
在 API 26 上已被弃用。
我应该改用什么?
根据 reference,自 Android 8.0+(API 26+)起被 getter getSerial()
弃用。
另外,您需要 Manifest.permission.READ_PHONE_STATE 许可。
根据 docs 使用 Build.getSerial()
。请注意,这需要 READ_PHONE_STATE
权限。
Build.SERIAL
This field was deprecated in API level 26. Use getSerial() instead.
备注
[...] For apps targeting SDK higher than Build.VERSION_CODES.O_MR1 this
field is set to UNKNOWN.
我刚刚将我的应用程序更新为 API 26,我正在尝试检索设备的序列号,但我发现 Build.SERIAL
在 API 26 上已被弃用。
我应该改用什么?
根据 reference,自 Android 8.0+(API 26+)起被 getter getSerial()
弃用。
另外,您需要 Manifest.permission.READ_PHONE_STATE 许可。
根据 docs 使用 Build.getSerial()
。请注意,这需要 READ_PHONE_STATE
权限。
Build.SERIAL
This field was deprecated in API level 26. Use getSerial() instead.
备注
[...] For apps targeting SDK higher than Build.VERSION_CODES.O_MR1 this field is set to UNKNOWN.