asullaherc asullaherc - 2 months ago 105
Android Question

How to listen ACTION_MANAGE_OVERLAY_PERMISSION is allowed

I use following code:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
startActivityForResult(intent, 5469);


to get SYSTEM_ALERT_WINDOW permission, how to run code after this permission is allowed

Answer

When use this requestPermissions

    ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
                REQUEST_SDCARD);

Then use this code:

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
                                           @NonNull int[] grantResults) {


        }
    }

When use this code

Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
                Uri.parse("package:" + getPackageName()));
        startActivityForResult(intent, 5469);

Then use this code:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(requestCode==5469)
    {


    }
}
Comments