2

How can I get IMEI number up to API level 19 (kitkat) in Android programming?

I have used getDeviceID(telephonyManager) but it is working only up to API 22 not below for API level 19.

Is there any other function that can be used?

1 Answer 1

1

You may try this:

TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) { return; } String IMEI_Number = telephonyManager.getDeviceId(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { String Imei0Id = telephonyManager.getDeviceId(0); // hear 0 is slot number if (null != Imei0Id && !Imei0Id.equals("000000000000000")) { IMEI_Number = Imei0Id; } } 

also check this link for good concept

https://developer.android.com/reference/android/telephony/TelephonyManager

on left side you found API Level Option that I mentioned in below picture by red mark. It will shows which are used by or not. enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.