Hi,
I'm using the READ_PHONE_STATE on an app with target API < 23 to read the
IMEI of devices.
The problem is that when install my app on an android M, I get the correct
IMEI until I revoke the permission in the settings. Then the value is
"null", but there is no SecurityException thrown, and checks for permission
at runtime tell me the permission is granted :
String permission = "android.permission.READ_PHONE_STATE";
int res = context.checkCallingOrSelfPermission(permission);
if(res != PackageManager.PERMISSION_GRANTED)
{
//never gets here
}
PackageManager pm = context.getPackageManager();
int hasPerm = pm.checkPermission(android.Manifest.permission.
READ_PHONE_STATE, context.getPackageName());
if (hasPerm != PackageManager.PERMISSION_GRANTED)
{
//never gets here
}
if(ContextCompat.checkSelfPermission(this, Manifest.permission.
READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED)
{
//never gets here
}
Since some devices actually have a null IMEI, I cannot check for the null
value as a proof that that app does not have the permission anymore.
Is there a way to know that the permission is now denied without upgrading
to target API 23?
--
You received this message because you are subscribed to the Google Groups
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/android-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/android-developers/90c9c432-ee70-4fc1-bd9a-1ef7871cb043%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.