In android 10, couldn't get device id using permission "READ_PHONE_STATE". I got an error while trying to get deviceID "The user 10296 does not meet the requirements to access device identifiers". I referred the developer site, but couldn't get proper solution. Also "READ_PRIVILEGE_PHONE_STATE" permission also not accessible.
Please prefer any solution to get deviceID from Android 10 mobile's and help me to resolve this issue. Thanks in advance
getDeviceId() has been deprecated since API level 26.
"READ_PRIVILEGE_PHONE_STATE" is only accessible by The best practices suggest that you should "Avoid using hardware identifiers." for unique identifiers. You can use an instance id from firebase e.g FirebaseInstanceId.getInstance().getId();.
Or you can generate a custom globally-unique ID (GUID) to uniquely identify the app instance e.g
String uniqueID = UUID.randomUUID().toString();
or the least recommended way
String deviceId = android.provider.Settings.Secure.getString(
context.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
You can also use this one, it's getting token from Firebase:-
String deviceId = FirebaseInstanceId.getInstance().getToken();
and this way is also working:-
String deviceId = UUID.randomUUID().toString();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With