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
Capital Gains Rules for Military Families • KateHorrell
Top 5 Tax Questions for Fulltime Families - Preparing Your Taxes | Fulltime Families
9.4: Resonance Lewis Structures
Drury Inn & Suites Bowling Green
Friskies Tender And Crunchy Recall
Duralast Gold Cv Axle
Dricxzyoki
Nehemiah 4:1–23
Dew Acuity
Meer klaarheid bij toewijzing rechter
Ub Civil Engineering Flowsheet
Lenscrafters Westchester Mall
Craigslist Cars And Trucks Buffalo Ny
今月のSpotify Japanese Hip Hopベスト作品 -2024/08-|K.EG
Spectrum Field Tech Salary
Commodore Beach Club Live Cam
Walmart Car Department Phone Number
Lowes Undermount Kitchen Sinks
Nz Herald Obituary Notices
Scream Queens Parents Guide
Knock At The Cabin Showtimes Near Alamo Drafthouse Raleigh
12 Facts About John J. McCloy: The 20th Century’s Most Powerful American?
Kirsten Hatfield Crime Junkie
Craiglist.nj
The Banshees Of Inisherin Showtimes Near Broadway Metro
Marokko houdt honderden mensen tegen die illegaal grens met Spaanse stad Ceuta wilden oversteken
Does Circle K Sell Elf Bars
Rund um die SIM-Karte | ALDI TALK
Salons Open Near Me Today
Sun-Tattler from Hollywood, Florida
Solve 100000div3= | Microsoft Math Solver
Tyler Sis 360 Boonville Mo
Helloid Worthington Login
Jennifer Reimold Ex Husband Scott Porter
oklahoma city community "puppies" - craigslist
Wildfangs Springfield
World History Kazwire
Craigslist En Brownsville Texas
Jasgotgass2
Sams Gas Price Sanford Fl
COVID-19/Coronavirus Assistance Programs | FindHelp.org
The power of the NFL, its data, and the shift to CTV
Autum Catholic Store
Petra Gorski Obituary (2024)
844 386 9815
Sapphire Pine Grove
Mmastreams.com
Walmart Front Door Wreaths
Publix Store 840
Coleman Funeral Home Olive Branch Ms Obituaries
View From My Seat Madison Square Garden
March 2023 Wincalendar
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.