How to get Unique ID to identify Android devices | en.proft.me (2024)

How to get Unique ID to identify Android devices Android 13.06.2017

How to get Unique ID to identify Android devices | en.proft.me (1)

Sometimes it is required to get the unique ID of android device (phone, tablet, tv, wear) while developing the android application. There are several solutions and we going to examine them all.

Secure Android ID

On a device first boot, a randomly value is generated and stored. This value is available via Settings.Secure.ANDROID_ID. It’s a 64-bit number that should remain constant for the lifetime of a device. ANDROID_ID seems a good choice for a unique device identifier because it’s available for smartphones and tablets. To retrieve the value, you can use the following code:

String androidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID);

However, the value may change if a factory reset is performed on the device. There is also a known bug with a popular handset from a manufacturer where every instance have the same ANDROID_ID.

Be aware that ANDROID_ID could be changed after user switch (multiuser in 4.2).

But, accordingly to googleblog.com ANDROID_ID is the preferred device identifier. ANDROID_ID is perfectly reliable on versions of Android <=2.1 or >=2.3. Only 2.2 has the problems.

UUID

As the requirement for most of applications is to identify a particular installation and not a physical device, a good solution to get unique id for an user if to use UUID class.

String uniqueID = UUID.randomUUID().toString(); 

UUID.randomUUID() method generates an unique identifier for a specific installation. You have just to store that value and your user will be identified at the next launch of your application.

Unique Telephony Number (IMEI, MEID, ESN, IMSI)

If you only target smartphones, you can take profit of the fact that the device have telephony services. So, you can easily retrieve an unique ID identifying the device.

This unique ID can be IMEI, MEID, ESN or IMSI. They can be defined as follows:

  • IMEI for International Mobile Equipment Identity: the Unique Number to identify GSM, WCDMA mobile phones as well as some satellite phones.
  • MEID for Mobile Equipment IDentifier: the globally unique number identifying a physical piece of CDMA mobile station equipment, the MEID was created to replace ESNs (Electronic Serial Number).
  • ESN for Electronic Serial Number: the unique number to identify CDMA mobile phones.
  • IMSI (International Mobile Subscriber Identity): the unique identification associated with all GSM and UMTS network mobile phone users.

To retrieve the unique ID associated to your device, you can use the following code:

TelephonyManager telephonyManager;telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);// getDeviceId() returns the unique device ID.// for example, the IMEI for GSM and the MEID or ESN for CDMA phonesString deviceId = telephonyManager.getDeviceId();// getSubscriberId() returns the unique subscriber ID,// for example, the IMSI for a GSM phone.String subscriberId = telephonyManager.getSubscriberId();

Advantages of using IMEI as Device ID:

  • The IMEI is unique for each and every device.
  • It remains unique for the device even if the application is re-installed or if the device is rooted or factory reset.

Disadvantages of using IMEI as Device ID:

  • IMEI is dependent on the simcard slot of the device, so it is not possible to get the IMEI for the devices that do not use Simcard.
  • In Dual sim devices, we get 2 different IMEIs for the same device as it has 2 slots for simcard.
  • This solution needs to request for android.permission.READ_PHONE_STATE to your user which can be hard to justify following the type of application you have made.

MAC and Bluetooth address

You can also try to get a MAC Address from a device having a Wi-Fi or Bluetooth hardware. But, this solution is not recommended because not all of the device have Wi-Fi connection. Even if the user have a Wi-Fi connection, it must be turned on to retrieve the data. Otherwise, the call doesn’t report the MAC Address.

But it's better to avoid MAC address because these are no more accessible to application in Android v6.0 MarshMallow: To provide users with greater data protection, starting in this release, Android removes programmatic access to the device’s local hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress() methods now return a constant value of 02:00:00:00:00:00.

How to get Unique ID to identify Android devices | en.proft.me (2024)
Top Articles
Recovering from Viruses, Worms, and Trojan Horses | CISA
Public information and stablecoin runs
Automated refuse, recycling for most residences; schedule announced | Lehigh Valley Press
Places 5 Hours Away From Me
Craigslist Benton Harbor Michigan
What's New on Hulu in October 2023
State Of Illinois Comptroller Salary Database
Red Heeler Dog Breed Info, Pictures, Facts, Puppy Price & FAQs
Taylor Swift Seating Chart Nashville
Huge Boobs Images
iOS 18 Hadir, Tapi Mana Fitur AI Apple?
boohoo group plc Stock (BOO) - Quote London S.E.- MarketScreener
Mals Crazy Crab
Yakimacraigslist
The best TV and film to watch this week - A Very Royal Scandal to Tulsa King
Carson Municipal Code
No Hard Feelings - Stream: Jetzt Film online anschauen
Strange World Showtimes Near Roxy Stadium 14
Craigslist Southern Oregon Coast
Costco Great Oaks Gas Price
Gayla Glenn Harris County Texas Update
Project, Time & Expense Tracking Software for Business
Gina Wilson All Things Algebra Unit 2 Homework 8
U Of Arizona Phonebook
Tips and Walkthrough: Candy Crush Level 9795
Shreveport City Warrants Lookup
Cookie Clicker Advanced Method Unblocked
When Does Subway Open And Close
Obituaries Milwaukee Journal Sentinel
Kirsten Hatfield Crime Junkie
Dmv In Anoka
Watson 853 White Oval
Wolfwalkers 123Movies
Uncovering the Enigmatic Trish Stratus: From Net Worth to Personal Life
Japanese Emoticons Stars
Emuaid Max First Aid Ointment 2 Ounce Fake Review Analysis
Courtney Roberson Rob Dyrdek
Chadrad Swap Shop
2487872771
Back to the Future Part III | Rotten Tomatoes
Arcadia Lesson Plan | Day 4: Crossword Puzzle | GradeSaver
Section 212 at MetLife Stadium
Callie Gullickson Eye Patches
Sdn Fertitta 2024
3 Zodiac Signs Whose Wishes Come True After The Pisces Moon On September 16
bot .com Project by super soph
Bellelement.com Review: Real Store or A Scam? Read This
The Quiet Girl Showtimes Near Landmark Plaza Frontenac
Call2Recycle Sites At The Home Depot
Game Akin To Bingo Nyt
Craigslist Cars And Trucks For Sale By Owner Indianapolis
Latest Posts
Article information

Author: Carlyn Walter

Last Updated:

Views: 6084

Rating: 5 / 5 (70 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Carlyn Walter

Birthday: 1996-01-03

Address: Suite 452 40815 Denyse Extensions, Sengermouth, OR 42374

Phone: +8501809515404

Job: Manufacturing Technician

Hobby: Table tennis, Archery, Vacation, Metal detecting, Yo-yoing, Crocheting, Creative writing

Introduction: My name is Carlyn Walter, I am a lively, glamorous, healthy, clean, powerful, calm, combative person who loves writing and wants to share my knowledge and understanding with you.