如何收听ACTION_MANAGE_OVERLAY_PERMISSION是允许的

时间:2016-05-15 11:23:59

标签: java android

我使用以下代码:

    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);

获取SYSTEM_ALERT_WINDOW权限,如何在允许此权限后运行代码

1 个答案:

答案 0 :(得分:1)

使用此requestPermissions时

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

然后使用此代码:

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


        }
    }

使用此代码时

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

然后使用此代码:

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


    }
}