2

It seems that from Android API 23 you must explicitly request a permission for drawing over other apps.

As of API level 23, an app cannot draw on top of other apps unless it declares the SYSTEM_ALERT_WINDOW permission in its manifest, and the user specifically grants the app this capability.

The second requirement (you must send an intent) is very badly implemented as it doesn't popup the new permissions window with Allow/Disallow buttons, but instead sends the user to a completely new settings page where the user must switch a toggle button and then navigate back to get back to the app.

If the second step is not met, the app will throw Unable to add window permission denied for this window type error.

However - such apps as Twilight or Facebook Messenger do not require user to switch that permission (I was not navigated to that settings screen) and yet they are able to draw over all apps.

How do Facebook, Twilight and similar apps get around this new requirement?

Arturs Vancans
  • 4,531
  • 14
  • 47
  • 76
  • Call google. Tell them you are important as facebook and want that permission removed for you. They whitelist you. Problem solved. – Chris Franklin Jan 11 '16 at 21:00
  • @ChrisFranklin If only.. but I don't believe it is legally allowed to whitelist certain apps. – Arturs Vancans Jan 11 '16 at 21:10
  • I am serious. Not only is it 100% legal, it is common practice. Apps like that are what are known as 2nd party applications. They have more lenient permission requirements because they have a signed liability contract with Google. Having worked on one of those apps, trust me, they exist. If you want to become a 2nd party app, become much more popular and deemed as something that can't be lived without. – Chris Franklin Jan 11 '16 at 21:23

2 Answers2

1

Not a direct solution to the problem, but a workaround - set android:targetSdkVersion to 22.

This will still work fine with Android 6 but you will lose a few features that came with API23.

Arturs Vancans
  • 4,531
  • 14
  • 47
  • 76
0

https://stackoverflow.com/a/33895409/1979882

use google

the user can manually set this properties:

and you can read them using: Settings.canDrawOverlays(context);

Community
  • 1
  • 1
Vyacheslav
  • 26,359
  • 19
  • 112
  • 194
  • Read my post, the way user has to set up those permissions is via Settings Page (and not a popup) which is not user friendly. – Arturs Vancans Jan 12 '16 at 10:35