How to find the serial number of the device with Android. I need a serial number that is in About device -> Status -> Serial number
Build.Serial returns to me a different value
Use this upto Android 7.1(SDK 25)
Build.SERIAL
And this for Android 8(SDK 26+)
Build.getSerial()
You can use this gist file for get device id. It works on all device before android Pie. If you targeting pie so you can add below code on gist file.
if (serialNumber.equals("unknown")){ try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { serialNumber = Build.getSerial(); } } catch (SecurityException e) { e.printStackTrace(); Log.d("responseData", String.valueOf(e.getMessage())); } } put this code above this line of code
// If none of the methods above worked if (serialNumber.equals("")) { serialNumber = null; } I tried this code on Nokia 6.1 plus and its working.