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.