You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi could you please give a suggestion/solution for checkOpNoThrow deprecated issue
Here is my code for checking MIUI special permissions, and its working fine, but in android studio they give a deprecated waring for checkOpNoThrow
They mentioned instead of using checkOpNoThrow use unsafeCheckOpNoThrow
but when I use unsafeCheckOpNoThrow, I got an exception like
java.lang.IllegalArgumentException: method android.app.AppOpsManager.unsafeCheckOpNoThrow argument 1 has type java.lang.String, got java.lang.Integer
at java.lang.reflect.Method.invoke(Native Method)
But I have no prior experience in Android side, Could you pls help me.
public static boolean isCustomPermissionGranted(Context context, int permission) {
Log.d(TAG,"The result is------------ ");
try {
AppOpsManager mgr = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
Method m = AppOpsManager.class.getMethod("unsafeCheckOpNoThrow", int.class, int.class, String.class);
int result = (int) m.invoke(mgr, permission, android.os.Process.myUid(), context.getPackageName());
return result == AppOpsManager.MODE_ALLOWED;
} catch (Exception e) {
Log.d(TAG,"The result is------------ ",e);
}
return false;
}
Is the issue mentioned in the framework documentation? [Required]
Not Selected
Did you consult the framework documentation but couldn't find a solution? [Required]
Not Selected
Has a similar issue been reported in the issue list? [Required]
Not Selected
Have you searched the issue list but couldn't find a solution? [Required]
Yes
The text was updated successfully, but these errors were encountered:
Question Description [Required]
Hi could you please give a suggestion/solution for
checkOpNoThrow
deprecated issueHere is my code for checking
MIUI
special permissions, and its working fine, but in android studio they give a deprecated waring forcheckOpNoThrow
They mentioned instead of using
checkOpNoThrow
useunsafeCheckOpNoThrow
but when I use
unsafeCheckOpNoThrow
, I got an exception likeBut I have no prior experience in Android side, Could you pls help me.
Is the issue mentioned in the framework documentation? [Required]
Not Selected
Did you consult the framework documentation but couldn't find a solution? [Required]
Not Selected
Has a similar issue been reported in the issue list? [Required]
Not Selected
Have you searched the issue list but couldn't find a solution? [Required]
Yes
The text was updated successfully, but these errors were encountered: