I am getting IMEI null in Android Q?
Android Q has restricted to access for both IMEI and serial no. It is available only for platform and apps with special carrier permission. Also the permission READ_PRIVILEGED_PHONE_STATE is not available for non platform apps.
If you try to access it throws below exception
java.lang.SecurityException: getImeiForSlot: The user 10180 does not meet the requirements to access device identifiers.
Please refer documentation:
https://developer.android.com/preview/privacy/data-identifiers#device-ids
Also refer Issue
TelephonyManager returns null for IMEI number: what can cause this?
After your comment, to get unique device id for the survey app, i would suggest you to use Settings.Secure.ANDROID_ID
as your unique id.
String myAndroidDeviceId = Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID);
Or you can use both as
public String getUniqueID(){
String myAndroidDeviceId = "";
TelephonyManager mTelephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (mTelephony.getDeviceId() != null){
myAndroidDeviceId = mTelephony.getDeviceId();
}else{
myAndroidDeviceId = Secure.getString(getApplicationContext().getContentResolver(), Secure.ANDROID_ID);
}
return myAndroidDeviceId;
}
Related Topics
How to Use Sharedpreferences in Xamarin.Android
Android Mediaplayer Stop and Play
How to Free a Component in Android/Ios
Android Gettext from Edittext Field
How to Simulate :Active CSS Pseudo Class in Android on Non-Link Elements
What's Dp (Density Independent Pixels) Units with CSS
Scrollable Content Inside an HTML Does Not Scroll in Android Emulator or Phone
How to Scale a Website for Mobile Devices
Android/Webkit Text-Overflow: Ellipsis Not Working
How to Create Spinner-List Using Customadapter in Android
How to Transfer the Formatted Date String from My Datepickerfragment
Flinging with Recyclerview + Appbarlayout
How to Add an Android Studio Project to Github
How to Convert a Bitmap to Drawable in Android
Android: Disabling Highlight on Listview Click