2
I am using the following code to get the device serial number:
String serial = Build.class.getField("SERIAL").get(null);
But the result is not the same when I check the serial number on the device.
2
I am using the following code to get the device serial number:
String serial = Build.class.getField("SERIAL").get(null);
But the result is not the same when I check the serial number on the device.
4
According to the documentation must use
Build.getSerial();
which returns the hardware serial number, if available.
Requires API level 26 and requires permission READ_PHONE_STATE
.
In previous versions use Build.SERIAL.
If the reason to get Serial is to want to identify the device the application is running on, take into account what is said in Best practices for unique identifiers.
May also be useful: Changes to Device Identifiers in Android.
Browser other questions tagged android
You are not signed in. Login or sign up in order to post.
This method does not appear to me in the class
Build
.– Murilo Fechio
Keeps returning me a different value when accessing the cell phone: Settings - > About the device -> Status -> Serial number
– Murilo Fechio
Which one you’re wearing
Build.SERIAL
orBuild.getSerial();
?– ramaral
Build.SERIAL
which gives the same result asBuild.class.getField("SERIAL").get(null)
of my initial question– Murilo Fechio
These are the forms the documentation indicates to obtain the serial number. If they do not work it is because, perhaps, the manufacturer does not implement them correctly. If so there is nothing to do, at least that I know.
– ramaral