How to programmatically grant the “draw over other apps” permission in android?

前端 未结 3 874
孤城傲影
孤城傲影 2020-12-05 16:58

How can I programmatically grant the permission in Settings -> Apps -> Draw over other apps in Android? I want to use system alert window but unable to in

3条回答
  •  离开以前
    2020-12-05 17:16

    You can check and ask for overlay permission to draw over other apps using this

    if (!Settings.canDrawOverlays(this)) {
        Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
        startActivityForResult(intent, 0);
    }
    

提交回复
热议问题