Skip to content

Instantly share code, notes, and snippets.

@tiwiz
Created November 23, 2015 16:03
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tiwiz/9d6561f54fac3035ee8e to your computer and use it in GitHub Desktop.
Save tiwiz/9d6561f54fac3035ee8e to your computer and use it in GitHub Desktop.
Draw over other apps on Android 6
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
public void onClick(View v) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse(String.format("package:%s", getPackageName())));
startActivityForResult(intent, DRAW_OVER_OTHER_APPS);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == DRAW_OVER_OTHER_APPS) {
if (Settings.canDrawOverlays(this)) {
//Freely draw over other apps
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment