Closed ch-muhammad-adil closed 8 years ago
So I have managed to solve this issue. here is my solution ...
We need to get permissions for this app to draw on system window so here I used this code
if (Build.VERSION.SDK_INT >= 23) {
checkDrawOverlayPermission();
}else{
StandOutWindow.closeAll(this, Dpad.class);
StandOutWindow.show(this, Dpad.class, StandOutWindow.DEFAULT_ID);
finish();
}
here is the rest work I have done.
get the permissions from the user
`/**
* code to post/handler request for permission
*/
public final static int REQUEST_CODE = 5463&0xffffff00;
public void checkDrawOverlayPermission() {
/** check if we already have permission to draw over other apps */
if (!Settings.canDrawOverlays(getApplicationContext())) {
/** if not construct intent to request permission */
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
/** request permission via start activity for result */
startActivityForResult(intent, REQUEST_CODE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
/** check if received result code
is equal our requested code for draw permission */
if (requestCode == REQUEST_CODE) {
// / ** if so check once again if we have permission */
if (Settings.canDrawOverlays(this)) {
StandOutWindow.closeAll(this, Dpad.class);
StandOutWindow.show(this, Dpad.class, StandOutWindow.DEFAULT_ID);
finish();
}
}
}`
Hey thank you for this library..
I am facing this issue at Android 6.