ask for overlay permission on android 10 only

This commit is contained in:
Milos Kozak 2020-02-06 21:24:19 +01:00
parent 7b984550ea
commit 42c2d89f98

View file

@ -133,20 +133,20 @@ public class AndroidPermission {
}
public static synchronized void notifyForSystemWindowPermissions(Activity activity) {
// Check if Android Q or higher
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
if (!Settings.canDrawOverlays(activity)) {
NotificationWithAction notification = new NotificationWithAction(Notification.PERMISSION_SYSTEM_WINDOW, MainApp.gs(R.string.needsystemwindowpermission), Notification.URGENT);
notification.action(R.string.request, () -> {
// Check if Android Q or higher
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
// Show alert dialog to the user saying a separate permission is needed
// Launch the settings activity if the user prefers
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + activity.getPackageName()));
activity.startActivity(intent);
}
});
RxBus.INSTANCE.send(new EventNewNotification(notification));
} else
RxBus.INSTANCE.send(new EventDismissNotification(Notification.PERMISSION_SYSTEM_WINDOW));
}
}
}