3

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

enter image description here

4 Answers 4

9

Use this upto Android 7.1(SDK 25)

Build.SERIAL

And this for Android 8(SDK 26+)

Build.getSerial()

Sign up to request clarification or add additional context in comments.

1 Comment

For me the old call give me the serial on older OS versions. A newer device (S8 running Oreo) gives me a serial but not the serial. Meaning: I get a serial number but not the same as the serial which is visible to a user in the UI (image in the question). Don't know if this is a obfuscation due to security or a Samsung-specific thing or what. Worth noting though if you need a number that your user can communicate to you in support situations or something.
2

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.

Comments

0

You can be get the android serial number using this

Build.SERIAL 

Comments

-6

Actually,

Build.SERIAL

works fine on old and new APIs. Tested on: API 16 API 23 API 26 API 28

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.