Some devices have extra security features and check if an app is drawing on top of others, when showing a permission dialog.
I have a sidebar app, and my app has to be disabled, before users can accept a system dialog.
Questions
EDIT
One solution I can think of is following:
Using the AccessibilityService
to check current foreground apps/views. There I will be able to check events that show me current foreground activities and even views...
My problems:
As far as I know, what you want isn't possible. In a similar question , there is a solution to detect system dialogs, but I don't think it will work for your overlay (only for the currently active activity).
Another question suggests that it may be possible to monitor system dialogs via the ActivityManager class, but that API has been deprecated since LOLIPOP.
For these reasons, I suggest you to add a pause button to your overlay. Or even better, use a sticky notification with stop/start buttons so users can manually pause your overlay.
public boolean isSystemApp(String packageName) { try { // Get packageinfo for target application PackageInfo targetPkgInfo = mPackageManager.getPackageInfo( packageName, PackageManager.GET_SIGNATURES); // Get packageinfo for system package PackageInfo sys = mPackageManager.getPackageInfo( "android", PackageManager.GET_SIGNATURES); // Match both packageinfo for there signatures return (targetPkgInfo != null && targetPkgInfo.signatures != null && sys.signatures[0] .equals(targetPkgInfo.signatures[0])); } catch (PackageManager.NameNotFoundException e) { return false; } }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.