Note that I'm talking about Android Lollipop. For android 6.0 we can use method canDrawOverlays()
to check that SYSTEM_ALERT_WINDOW
is granted or not.
With Android Lollipop, almost devices grant this permission by default. But on some devices of Xiaomi, Meizu.. it is not granted. Users need to go to the App info to allow it.
How can we check it programmatically to warn users?
in MIUI use
Reflection is risky because you take things for granted...and things can change in future versions of Android. The following method only uses reflection if the proper way fails.