Answer the question
In order to leave comments, you need to log in
Why is onActivityResult() deprecated?
Tells AndroidStudio that the onActivityResult() method has been deprecated.
Googled the new implementation:
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);
}
Answer the question
In order to leave comments, you need to log in
Obviously, a new method must be used. In new versions of android, this method can be bang (or it just won’t work), and then you will rewrite with your ass on fire. So far, they just marked deprecated so that everyone would stop using it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question