-1

Android Developer Device ID Depricated

Android has changed the getDeviceID() it says to use @link getMeid which user READ_PHONE_STATE permission where the security level of this permission is Dangerous

As the permission level is dangerous i m looking for any alternate way to Get IMEI Number.

I tried using getUniqueid() but it is generating a unique number each time.

Kindly let me know any alternate way to maintain device singularity. Thanks in Advance.

ADM
  • 20,406
  • 11
  • 52
  • 83
  • check this https://stackoverflow.com/a/46744134/7666442 – AskNilesh Mar 05 '19 at 07:06
  • What are you actually using it for? Its highly unlikely you actually want the IMEI- for one thing not all devices have one (any wireless only tablet will not, for example). If you just want a unique id, check out https://developer.android.com/training/articles/user-data-ids – Gabe Sechan Mar 05 '19 at 07:08

1 Answers1

0

Returns the unique device ID of a subscription, for example, the IMEI for GSM and the MEID for CDMA phones. Return null if device ID is not available.

This method was deprecated in API level 26.

Use (@link getImei} which returns IMEI for GSM

or (@link getMeid} which returns MEID for CDMA.

Try this to get IMEI

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            String imei = telephonyMgr.getImei();
} else {
            String imei = telephonyMgr.getDeviceId();
}
Aravind V
  • 358
  • 2
  • 10