Reputation: 4337
My app is totally relying on the SYSTEM_ALERT_WINDOW
permission to work, when I tried to grant this permission using the below code:
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getApplicationContext().getPackageName()));
startActivityForResult(intent, 12);
App crash with the following :
Caused by: android.content.ActivityNotFoundException: No Activity found to handle Intent
{ act=android.settings.action.MANAGE_OVERLAY_PERMISSION dat=package:maa.tv.tools_app}
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1798)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512)
at android.app.Activity.startActivityForResult(Activity.java:3917)
at android.app.Activity.startActivityForResult(Activity.java:3877)
The test environment :
Android TV running Android 23 Marshmallow
Notice: When I change the TargetSDK from 34 to 16, the Android OS automatically grants the permission, and the app works as intended. That's mean the permission is indeed exist in the Android TV OS.
Notice 2 : using adb shell appops set maa.tv.tools_app SYSTEM_ALERT_WINDOW allow
makes the app works as intended
So, when the targetSDK is lower than 23, does the Android OS automatically grant the permission using adb shell, right?
Any explication, thank you.
Upvotes: 2
Views: 191
Reputation: 862
Android TV does not have the main settings app installed, instead TvSettings app is available on Android TV device. TvSettings does not have an activity for managing this permission, so when you ask for the permission, no activity will be found.
Upvotes: 0