Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 897
Francisco Durdin Garcia Avatar asked Dec 03 '22 20:12

Francisco Durdin Garcia


2 Answers

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

like image 75
Levi Moreira Avatar answered Dec 06 '22 10:12

Levi Moreira


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.

like image 38
Abner Escócio Avatar answered Dec 06 '22 10:12

Abner Escócio