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
[Solved] What happens When You Stop Paying For Cloud Storage?
Gmail Archive vs. Delete: When to Do Each, and Why
Dainty Rascal Io
Celebrity Extra
Nwi Police Blotter
Tv Guide Bay Area No Cable
10 Popular Hair Growth Products Made With Dermatologist-Approved Ingredients to Shop at Amazon
Videos De Mexicanas Calientes
Paketshops | PAKET.net
Ohiohealth Esource Employee Login
Large storage units
Https //Advanceautoparts.4Myrebate.com
Immediate Action Pathfinder
Superhot Unblocked Games
Craigslist Pets Longview Tx
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Mzinchaleft
Tygodnik Polityka - Polityka.pl
Effingham Bookings Florence Sc
Mahpeople Com Login
How to Watch the Fifty Shades Trilogy and Rom-Coms
EASYfelt Plafondeiland
Dwc Qme Database
Great Clips Grandview Station Marion Reviews
Putin advierte que si se permite a Ucrania usar misiles de largo alcance, los países de la OTAN estarán en guerra con Rusia - BBC News Mundo
Mtr-18W120S150-Ul
Haunted Mansion Showtimes Near Epic Theatres Of West Volusia
Rogue Lineage Uber Titles
Dei Ebill
Synergy Grand Rapids Public Schools
Is Henry Dicarlo Leaving Ktla
Alternatieven - Acteamo - WebCatalog
Deleted app while troubleshooting recent outage, can I get my devices back?
Xemu Vs Cxbx
Best Weapons For Psyker Darktide
KITCHENAID Tilt-Head Stand Mixer Set 4.8L (Blue) + Balmuda The Pot (White) 5KSM175PSEIC | 31.33% Off | Central Online
Sabrina Scharf Net Worth
Hireright Applicant Center Login
3 bis 4 Saison-Schlafsack - hier online kaufen bei Outwell
Wilson Tire And Auto Service Gambrills Photos
Memberweb Bw
Tommy Bahama Restaurant Bar & Store The Woodlands Menu
Lyons Hr Prism Login
Booknet.com Contract Marriage 2
Sacramentocraiglist
Bonecrusher Upgrade Rs3
Lebron James Name Soundalikes
Is Chanel West Coast Pregnant Due Date
Skyward Login Wylie Isd
Powah: Automating the Energizing Orb - EnigmaticaModpacks/Enigmatica6 GitHub Wiki
How to Find Mugshots: 11 Steps (with Pictures) - wikiHow
Att Corporate Store Location
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.