Reputation: 5900
From Android 6 we have to handle overlay screen in application, I read somewhere that if application is downloaded from play store then by default overlay screen option is enable. I just want to make confirm is it true? Or for this we have to do extra coding. Currently I am using following code to call overlay screen enable for Android 6+ devices:
private void callOverlayScreen() {
if (!Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + BuildConfig.APPLICATION_ID));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(intent);
}
}
Currently my if condition is always true. If suppose I release application on play store then it will not go in if condition until user manually disable overlay screen?
Can we check this behavior without downloading application from playstore?
Upvotes: 2
Views: 1094
Reputation: 20268
Yes, you are right. SYSTEM_ALERT_WINDOW
permission is always granted, when app is installed from Play Store.
Have a look at another answer already provided on StackOverflow, that confirms that:
However be advised, that it only works for Play Store. If you'd like to publish app in Samsung Store or Amazon Store, then you might have problems with that.
Also have a look at different question, where Toast
was identified as the view, that might cause similar problems on some devices:
Screen overlay detected blocks Android permissions
Hope, that this answer clears some of your concerns.
Upvotes: 2
Reputation: 24937
Based on the documentation for SYSTEM_ALERT_WINDOW
, this permission is classified as
Protection level: signature
And
Note: If the app targets API level 23 or higher, the app user must explicitly grant this permission to the app through a permission management screen
For your question:
I read somewhere that if application is downloaded from play store then by default overlay screen option is enable.
Based on the documentation for Permission grant facilitated for Signature level permissions:
The system grants these app permissions at install time, but only when the app that attempts to use a permission is signed by the same certificate as the app that defines the permission.
Since your app won't be signed with same certificate as of system's, the Overlay permission won't be granted to your app at install time.
I would recommend you to keep your checking as it is.
Upvotes: 1
Reputation: 3688
In the official android documentation, it says:
Note: If the app targets API level 23 or higher, the app user must explicitly grant this permission to the app through a permission management screen.
Upvotes: 1