Manifest:
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />
<uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" />
Code activity.onCreate():
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && BuildConfig.DEBUG) {
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);
}
}
Problem: Settings.canDrawOverlays(this) returns false even so the permission has been already granted. Hasn't happened before update Pixel to Oreo.
Android version: 8.0.0
I've tried to update build tools: to 26.0.1 and target and compileSdk to 26. It helped on the first launch :after toggling on it returns true, but next time I launch application it returns false again.
The problem was in Android Oreo itself.
After I've installed security patch it disappeared.
Solution: Install latest security patch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With