'return to my app automatically when I allowed any of the settings screen permission made

if (!Settings.canDrawOverlays(this)) { Toast.makeText(this, "Please give my app this permission!", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivityForResult(intent,OVERLAY_PERMISSION_REQ_CODE); }

The above code is used for requesting manage overlay permission and the app goes to the overlay settings screen, after permission is allowed I want to return to my app from the settings permission screen automatically. But I could not do this, manually back is working fine when clicking the system back button or action bar back button.

protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
        Toast.makeText(this, "Permission Granted", Toast.LENGTH_SHORT).show();

    }
}

This is my onActivityResult code.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source