Android Get Serial Number

  1. Android 8 Get Serial Number
  2. Android Ndk Get Serial Number
  3. Android Get Battery Serial Number

To find your device’s serial number in the software, go to Settings System. Then jump into About Phone Status. Your device’s serial number will generally be located toward the bottom of this screen.

  1. A serial number is a unique, identifying number or group of numbers and letters assigned to an individual piece of hardware or software. Other things have serial numbers as well, though, including banknotes and other similar documents.
  2. Android: get a device's serial number. GitHub Gist: instantly share code, notes, and snippets. Skip to content. All gists Back to GitHub. Sign in Sign up.
  3. Hi there For the tablet device, how can I get the device serial number? I cannot use the Telephony class cause it returns me NULL. Is there any way to get it in that format which the Settings Status shows for device?
  4. Firstly, switch your Samsung Galaxy J4 off. Now take away the back cover of your Galaxy J4 along with the battery. You will come across a sticker sort of white label attached to it on the back side of the battery. There is where you will find the serial number of your.
  5. The serial number (IMEI code) of your mobile Type in the short code.#06# on your mobile and press the call key. Remove the battery from your mobile and look for the code on the back of your device. Consult the purchase receipt or warranty of your mobile.
Active5 years, 5 months ago

On my Android Tablet I go to Settings -> About Device -> StatusIn this screen I find a serial number with a length of 11 characters.I would like to read this serial number with Java.Anyone an idea how to do that?

user1364471user1364471

3 Answers

Use

For more details check this out.This is the device serial number.

For MDN or MEID of the device depending on which radio the phone uses (GSM or CDMA), try

and include the permission in the manifest file:

Tanuj WadhwaTanuj Wadhwa
1,2907 gold badges29 silver badges52 bronze badges

Very old question, but perhaps the solution from dev here still helps:

Community
PdXYPdXY
JohnJohn

Not the answer you're looking for? Browse other questions tagged javaandroid or ask your own question.

Active1 year ago

I need to use a unique ID for an Android app and I thought the serial number for the device would be a good candidate. How do I retrieve the serial number of an Android device in my app ?

Idolon
23.4k10 gold badges84 silver badges109 bronze badges
EnoEno
5,31818 gold badges49 silver badges78 bronze badges

16 Answers

getSystemService is a method from the Activity class. getDeviceID() will return the MDN or MEID of the device depending on which radio the phone uses (GSM or CDMA).

Each device MUST return a unique value here (assuming it's a phone). This should work for any Android device with a sim slot or CDMA radio. You're on your own with that Android powered microwave ;-)

hasemanhaseman
9,5488 gold badges37 silver badges38 bronze badges

As Dave Webb mentions, the Android Developer Blog has an article that covers this.

I spoke with someone at Google to get some additional clarification on a few items. Here's what I discovered that's NOT mentioned in the aforementioned blog post:

  • ANDROID_ID is the preferred solution. ANDROID_ID is perfectly reliable on versions of Android <=2.1 or >=2.3. Only 2.2 has the problems mentioned in the post.
  • Several devices by several manufacturers are affected by the ANDROID_ID bug in 2.2.
  • As far as I've been able to determine, all affected devices have the same ANDROID_ID, which is 9774d56d682e549c. Which is also the same device id reported by the emulator, btw.
  • Google believes that OEMs have patched the issue for many or most of their devices, but I was able to verify that as of the beginning of April 2011, at least, it's still quite easy to find devices that have the broken ANDROID_ID.

Based on Google's recommendations, I implemented a class that will generate a unique UUID for each device, using ANDROID_ID as the seed where appropriate, falling back on TelephonyManager.getDeviceId() as necessary, and if that fails, resorting to a randomly generated unique UUID that is persisted across app restarts (but not app re-installations).

ceph3us
5,4712 gold badges30 silver badges36 bronze badges
emmbyemmby
67.6k58 gold badges174 silver badges237 bronze badges

This code returns device serial number using a hidden Android API.

Wesley Wiser
7,2004 gold badges36 silver badges56 bronze badges
Roman SLRoman SL

Although, it is not guaranteed that the Android ID will be an unique identifier.

Anthony ForloneyAndroid serial number finderAnthony Forloney
74.8k12 gold badges107 silver badges111 bronze badges

There is an excellent post on the Android Developer's Blog discussing this.

It recommends against using TelephonyManager.getDeviceId() as it doesn't work on Android devices which aren't phones such as tablets, it requires the READ_PHONE_STATE permission and it doesn't work reliably on all phones.

Instead you could use one of the following:

  • Mac Address
  • Serial Number
  • ANDROID_ID

The post discusses the pros and cons of each and it's worth reading so you can work out which would be the best for your use.

Dave WebbDave Webb
162k51 gold badges292 silver badges292 bronze badges

For a simple number that is unique to the device and constant for its lifetime (barring a factory reset or hacking), use Settings.Secure.ANDROID_ID.

To use the device serial number (the one shown in 'System Settings / About / Status') if available and fall back to Android ID:

Edward BreyEdward Brey
28k11 gold badges142 silver badges199 bronze badges

The IMEI is good but only works on Android devices with phone. You should consider support for Tablets or other Android devices as well, that do not have a phone.

You have some alternatives like: Build class members, BT MAC, WLAN MAC, or even better - a combination of all these.

I have explained these details in an article on my blog, see: http://www.pocketmagic.net/?p=1662

radhooradhoo

Android 8 Get Serial Number

Since no answer here mentions a perfect, fail-proof ID that is both PERSISTENT through system updates and exists in ALL devices (mainly due to the fact that there isn't an individual solution from Google), I decided to post a method that is the next best thing by combining two of the available identifiers, and a check to chose between them at run-time.

Before code, 3 facts:

  1. TelephonyManager.getDeviceId() (a.k.a.IMEI) will not work well or at all for non-GSM, 3G, LTE, etc. devices, but will always return a unique ID when related hardware is present, even when no SIM is inserted or even when no SIM slot exists (some OEM's have done this).

  2. Since Gingerbread (Android 2.3) android.os.Build.SERIALmust exist on any device that doesn't provide IMEI, i.e., doesn't have the aforementioned hardware present, as per Android policy.

  3. Due to fact (2.), at least one of these two unique identifiers will ALWAYS be present, and SERIAL can be present at the same time that IMEI is.

Note: Fact (1.) and (2.) are based on Google statements

SOLUTION

With the facts above, one can always have a unique identifier by checking if there is IMEI-bound hardware, and fall back to SERIAL when it isn't, as one cannot check if the existing SERIAL is valid. The following static class presents 2 methods for checking such presence and using either IMEI or SERIAL:

I would advice on using getCleartextID_HARDCHECK. If the reflection doesn't stick in your environment, use the getCleartextID_SIMCHECK method instead, but take in consideration it should be adapted to your specific SIM-presence needs.

P.S.: Do please note that OEM's have managed to bug out SERIAL against Google policy (multiple devices with same SERIAL), and Google as stated there is at least one known case in a big OEM (not disclosed and I don't know which brand it is either, I'm guessing Samsung).

Disclaimer: This answers the original question of getting a unique device ID, but the OP introduced ambiguity by stating he needs a unique ID for an APP. Even if for such scenarios Android_ID would be better, it WILL NOT WORK after, say, a Titanium Backup of an app through 2 different ROM installs (can even be the same ROM). My solution maintains persistence that is independent of a flash or factory reset, and will only fail when IMEI or SERIAL tampering occurs through hacks/hardware mods.

leRobotleRobot
1,3101 gold badge16 silver badges27 bronze badges

There are problems with all the above approaches. At Google i/o Reto Meier released a robust answer to how to approach this which should meet most developers needs to track users across installations.

This approach will give you an anonymous, secure user ID which will be persistent for the user across different devices (including tablets, based on primary Google account) and across installs on the same device. The basic approach is to generate a random user ID and to store this in the apps shared preferences. You then use Google's backup agent to store the shared preferences linked to the Google account in the cloud.

Lets go through the full approach. First we need to create a backup for our SharedPreferences using the Android Backup Service. Start by registering your app via this link: http://developer.android.com/google/backup/signup.html

Android shell get serial number

Google will give you a backup service key which you need to add to the manifest. You also need to tell the application to use the BackupAgent as follows:

Get android serial number ue4

Then you need to create the backup agent and tell it to use the helper agent for sharedpreferences:

To complete the backup you need to create an instance of BackupManager in your main Activity:

Finally create a user ID, if it doesn't already exist, and store it in the SharedPreferences:

This User_ID will now be persistent across installations, even if the user switches devices.

For more information on this approach see Reto's talk here http://www.google.com/events/io/2011/sessions/android-protips-advanced-topics-for-expert-android-app-developers.html

And for full details of how to implement the backup agent see the developer site here: http://developer.android.com/guide/topics/data/backup.html I particularly recommend the section at the bottom on testing as the backup does not happen instantaneously and so to test you have to force the backup.

Stanley
1,0995 gold badges17 silver badges32 bronze badges
TechnoTonyTechnoTony

Another way is to use /sys/class/android_usb/android0/iSerial in an App with no permissions whatsoever.

To do this in java one would just use a FileInputStream to open the iSerial file and read out the characters. Just be sure you wrap it in an exception handler because not all devices have this file.

At least the following devices are known to have this file world-readable:

  • Galaxy Nexus
  • Nexus S
  • Motorola Xoom 3g
  • Toshiba AT300
  • HTC One V
  • Mini MK802
  • Samsung Galaxy S II

You can also see my blog post here: http://insitusec.blogspot.com/2013/01/leaking-android-hardware-serial-number.html where I discuss what other files are available for info.

insitusecinsitusec

As @haserman says:

But it's necessary including the permission in the manifest file:

cesardscesards
10.4k11 gold badges54 silver badges52 bronze badges

Unique device ID of Android OS Device as String.

but I strngly recommend this method suggested by Google::

JorgesysJorgesys
101k16 gold badges263 silver badges230 bronze badges

Build.SERIAL is the simplest way to go, although not entirely reliable as it can be empty or sometimes return a different value (proof 1, proof 2) than what you can see in your device's settings.

There are several ways to get that number depending on the device's manufacturer and Android version, so I decided to compile every possible solution I could found in a single gist. Here's a simplified version of it :

flawyteflawyte
5,5703 gold badges32 silver badges53 bronze badges

I know this question is old but it can be done in one line of code

String deviceID = Build.SERIAL;

MichaelStoddartMichaelStoddart
3,7693 gold badges20 silver badges39 bronze badges

I found the example class posted by @emmby above to be a great starting point. But it has a couple of flaws, as mentioned by other posters. The major one is that it persists the UUID to an XML file unnecessarily and thereafter always retrieves it from this file. This lays the class open to an easy hack: anyone with a rooted phone can edit the XML file to give themselves a new UUID.

I've updated the code so that it only persists to XML if absolutely necessary (i.e. when using a randomly generated UUID) and re-factored the logic as per @Brill Pappin's answer:

Carlos P

Android Ndk Get Serial Number

Carlos P
2,8331 gold badge27 silver badges46 bronze badges

Yes. It is a device hardware serial number and it is unique. So on api level 2.3 and above you can use android.os.Build.ANDROID_ID to get it. For below 2.3 API level use TelephonyManager.getDeviceID().

you can read this http://android-developers.blogspot.in/2011/03/identifying-app-installations.html

Android Get Battery Serial Number

Mahesh Ramchandra BhatkandeMahesh Ramchandra Bhatkande

Not the answer you're looking for? Browse other questions tagged androidserial-number or ask your own question.