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?
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.