从 Intent 中获取结果

Get result from an Intent

我想用 registerForActivityResult 检查 ACTION_MANAGE_OVERLAY_PERMISSION 这段代码不起作用,当我检查权限时,Toast“Ok”没有出现

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();
                    }
                }
            });```

那个Intent动作is not documented to return anything。所以,你永远不会得到 Activity.RESULT_OK.