Home > database >  Get result from an Intent
Get result from an Intent

Time:10-29

I want to check ACTION_MANAGE_OVERLAY_PERMISSION with registerForActivityResult And this code does't work, when i check the permission the Toast "Ok" does't appear

mStartForResult.launch(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION));

ActivityResultLauncher<Intent> mStartForResult = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(),
            new ActivityResultCallback<ActivityResult>() {
                @Override
                public void onActivityResult(ActivityResult result) {
                    if (result.getResultCode() == Activity.RESULT_OK) {
                        Toast.makeText(MainActivity.this,"Ok",Toast.LENGTH_SHORT).show();
                    }
                }
            });```

CodePudding user response:

That Intent action is not documented to return anything. So, you will never get Activity.RESULT_OK.

  • Related