Search
 
SCRIPT & CODE EXAMPLE
 

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);
}
Comment

start activity for result deprecated

var resultLauncher = registerForActivityResult(StartActivityForResult()) { result ->
    if (result.resultCode == Activity.RESULT_OK) {
        // There are no request codes
        val data: Intent? = result.data
        doSomeOperations()
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: java stream limit items 
Java :: kjk;ok 
Java :: get input in java using joptionpane 
Java :: flow dependency android 
Java :: try block in java 
Java :: How to count the number of islands (groups of adjacent 1s) in a grid of 1s (land) and 0s (water), in Java? 
Java :: replace substring at index java 
Java :: java string remove character 
Java :: how to convert string array to int in java 
Java :: keytool error: java.io.FileNotFoundException: c:UsersUSER_NAMEupload-keystore.jks (The system cannot find the path specified) 
Java :: modal css react 
Java :: eclipse java content assist 
Java :: conversion of string to integer in java 
Java :: tableau de classe java 
Java :: all possible valid IP addresses leetcode 
Java :: java float 0/0 
Java :: get first entry in set java 
Java :: how to remove duplicate elements from char array in java 
Java :: java break 2 for loops 
Java :: list files in directory java 
Java :: array.sort in java 
Java :: viewpager2 dependency 
Java :: java first letter to upper case 
Java :: how to find the length of a string in java without using length function 
Java :: javac celar 
Java :: find maximum in array java 
Java :: how to find absolute difference in java 
Java :: java files 
Java :: how to center a window in java 
Java :: printing multiple variables in java 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =