I've tested Android 13 devices and I've seen that some of them use the "Restricted Settings" and others don't. I want to check programatically if the current device has that feature. Is there some kind of API for that?
Android 13 Restricted Settings(Accessibility) API
Asked Answered
I also have this issue so I will try to explain in case anyone can help.
Basically we need to detect if the service is disabled on android 13 so we can navigate the user to settings so they can enable the unsafe perm then enable the service.
Is there some settings variable that we can use.
Better demonstrated by this video https://www.youtube.com/watch?v=0bcLjpfrmHw
But I believe i found the answer on a post
public static boolean hasAccessRestrictedPerm(Context context) {
try {
PackageManager packageManager = context.getPackageManager();
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0);
AppOpsManager appOpsManager = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
int mode = appOpsManager.checkOpNoThrow("android:access_restricted_settings", applicationInfo.uid, applicationInfo.packageName);
return (mode == AppOpsManager.MODE_ALLOWED);
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
In android 13 If restricted settings error means Your app should be live on play store. First your app live then restricted settings gone. No need to do extra stuff for android 13. Happy coding
© 2022 - 2024 — McMap. All rights reserved.
"Im looking for a way to know if the current Android 13 device has RS feature or not"
, you found a solution to it? – Evelinevelina