ask for overlay permission on android 10 only
This commit is contained in:
parent
7b984550ea
commit
42c2d89f98
1 changed files with 15 additions and 15 deletions
|
@ -133,20 +133,20 @@ public class AndroidPermission {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void notifyForSystemWindowPermissions(Activity activity) {
|
public static synchronized void notifyForSystemWindowPermissions(Activity activity) {
|
||||||
if (!Settings.canDrawOverlays(activity)) {
|
// Check if Android Q or higher
|
||||||
NotificationWithAction notification = new NotificationWithAction(Notification.PERMISSION_SYSTEM_WINDOW, MainApp.gs(R.string.needsystemwindowpermission), Notification.URGENT);
|
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
|
||||||
notification.action(R.string.request, () -> {
|
if (!Settings.canDrawOverlays(activity)) {
|
||||||
// Check if Android Q or higher
|
NotificationWithAction notification = new NotificationWithAction(Notification.PERMISSION_SYSTEM_WINDOW, MainApp.gs(R.string.needsystemwindowpermission), Notification.URGENT);
|
||||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
|
notification.action(R.string.request, () -> {
|
||||||
// Show alert dialog to the user saying a separate permission is needed
|
// Show alert dialog to the user saying a separate permission is needed
|
||||||
// Launch the settings activity if the user prefers
|
// Launch the settings activity if the user prefers
|
||||||
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
|
||||||
Uri.parse("package:" + activity.getPackageName()));
|
Uri.parse("package:" + activity.getPackageName()));
|
||||||
activity.startActivity(intent);
|
activity.startActivity(intent);
|
||||||
}
|
});
|
||||||
});
|
RxBus.INSTANCE.send(new EventNewNotification(notification));
|
||||||
RxBus.INSTANCE.send(new EventNewNotification(notification));
|
} else
|
||||||
} else
|
RxBus.INSTANCE.send(new EventDismissNotification(Notification.PERMISSION_SYSTEM_WINDOW));
|
||||||
RxBus.INSTANCE.send(new EventDismissNotification(Notification.PERMISSION_SYSTEM_WINDOW));
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue