Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

start activity for result 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);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #start #activity #result #deprecated
ADD COMMENT
Topic
Name
5+8 =