2

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?

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
PPD
  • 5,660
  • 12
  • 52
  • 86
  • `I read somewhere` Can you share the source of that info? Seems not intuitive for me. – azizbekian Apr 20 '18 at 07:51
  • Hi @azizbekian thanks for reply I think its from https://commonsware.com/blog/2017/05/11/system_alert_window-updates.html – PPD Apr 20 '18 at 07:55

3 Answers3

2

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:

SYSTEM_ALERT_WINDOW - How to get this permission automatically on Android 6.0 and targetSdkVersion 23

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.

R. Zagórski
  • 20,020
  • 5
  • 65
  • 90
1

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.

Abdul Wasae
  • 3,614
  • 4
  • 34
  • 56
1

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.

Sagar
  • 23,903
  • 4
  • 62
  • 62