简体   繁体   中英

Build.SERIAL is deprecated as of API 26: Android 8.0 Oreo

I just updated my application to API 26 and I'm trying to retrieve the serial of the device and I'm seeing that Build.SERIAL is deprecated on API 26.

What should I use instead?

Use Build.getSerial() as per the docs . Note that this requires the READ_PHONE_STATE permission.

Build.SERIAL

This field was deprecated in API level 26. Use getSerial() instead.

Note

[...] For apps targeting SDK higher than Build.VERSION_CODES.O_MR1 this field is set to UNKNOWN.

As per the reference , it is deprecated since Android 8.0+ (API 26+) by the getter getSerial() . Plus you need Manifest.permission.READ_PHONE_STATE permission.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM