this drives me crazy.... since my Smartphone has API > 23 my youtube overlay doesnt work anymore.... so i implemented all the neccessary stuff. Now, my app asks for the permission to draw overlays (SYSTEM_ALERT_WINDOW) and if i debug my app then i see that the permission is granted. But if i start the overlay i get this error msg:
AndroidRuntime: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to create service ...: android.view.WindowManager$BadTokenException: Unable to add window android.view.ViewRootImpl$W@479d57e -- permission denied for window type 2002
Permissions in Manifest are these:
<uses-permission android:name="android.permission.ACTION_MANAGE_OVERLAY_PERMISSION" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
i ask for permission:
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, MainActivity.PERMISSIONS_REQUEST_SYSTEM_ALERT_WINDOW);
i check the permission like this:
if (Settings.canDrawOverlays(this)) {
permissionShowYoutubeOverlayIsOK = true;
}
So, what the hell is wrong here ??
any help is appreciated!!!
bye phil