Answer the question
In order to leave comments, you need to log in
How to track what the user clicked in startResolutionForResult()?
I want the user to enable geolocation using the system dialog by calling
exception.startResolutionForResult([email protected], 45)
Answer the question
In order to leave comments, you need to log in
you need to track the result of clicking using ActivityForResult (), but as you know, this method is deprecated
// You can do the assignment inside onAttach or onCreate, i.e, before the activity is displayed
ActivityResultLauncher<Intent> someActivityResultLauncher = registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
new ActivityResultCallback<ActivityResult>() {
@Override
public void onActivityResult(ActivityResult result) {
if (result.getResultCode() == Activity.RESULT_OK) {
// There are no request codes
Intent data = result.getData();
doSomeOperations();
}
}
});
public void openSomeActivityForResult() {
Intent intent = new Intent(this, SomeActivity.class);
someActivityResultLauncher.launch(intent);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question