To identify each devices uniquely I would like to use the IMEI (or ESN number for CDMA devices). How to access this programmatically?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Or you can use the ANDROID_ID setting from Android.Provider.Settings.System (as described here strazerre.com).
This has the advantage that it doesn't require special permissions but can change if another application has write access and changes it (which is apparently unusual but not impossible).
Just for reference here is the code from the blog:
Implementation note: if the ID is critical to the system architecture you need to be aware that in practice some of the very low end Android phones & tablets have been found reusing the same ANDROID_ID (9774d56d682e549c was the value showing up in our logs)
The method getDeviceId() of TelephonyManager returns the unique device ID, for example, the IMEI for GSM and the MEID or ESN for CDMA phones. Return null if device ID is not available.
Java Code
XML
Permission Required READ_PHONE_STATE in manifest file.
Use below code gives you IMEI number:
New Update:
For Android Version 6 And Above, WLAN MAC Address has been deprecated , follow Trevor Johns answer
Update:
For uniquely Identification of devices, You can Use Secure.ANDROID_ID.
Old Answer:
Disadvantages of using IMEI as Unique Device ID:
You can Use The WLAN MAC Address string (Not Recommended For Marshmallow and Marshmallow+ as WLAN MAC Address has been deprecated on Marshmallow forward. So you'll get a bogus value)
We can get the Unique ID for android phones using the WLAN MAC address also. The MAC address is unique for all devices and it works for all kinds of devices.
Advantages of using WLAN MAC address as Device ID:
It is unique identifier for all type of devices (smart phones and tablets).
It remains unique if the application is reinstalled
Disadvantages of using WLAN MAC address as Device ID:
Give You a Bogus Value from Marshmallow and above.
If device doesn’t have wifi hardware then you get null MAC address, but generally it is seen that most of the Android devices have wifi hardware and there are hardly few devices in the market with no wifi hardware.
SOURCE : technetexperts.com