Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

startactivityforresult deprecated android

public void openSomeActivityForResult() {
    Intent intent = new Intent(this, SomeActivity.class);
    someActivityResultLauncher.launch(intent);
}

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

Android Studio startActivityForResult depreciated

    // 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

PREVIOUS NEXT
Code Example
Java :: how to loop through a 2d array java 
Java :: java how to make a gui 
Java :: java prime 
Java :: java get constructor 
Java :: free news api for android 
Java :: java swing pic 
Java :: java outer class 
Java :: convert int to double with 2 decimal places java 
Java :: java run system command 
Java :: JAVA_HOME not found in your environment. 
Java :: loop will array length java example 
Java :: java resource file 
Java :: get certain character from string java 
Java :: Java Hashmap Access Elements 
Java :: autowire and qualifier 
Java :: i have AdoptOpenJDK 8 but java --version gettinbg Unrecognized option: --version Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. 
Java :: do while loop in java 
Java :: get imei programmatically android 
Java :: How to do press enter to continue in java 
Java :: set visible gui java 
Java :: how to control clip volume java 
Java :: java find last element in array 
Java :: getting the last value of an integer in java 
Java :: counting nodes in binary search tree 
Java :: get text from a jtextfield 
Java :: android dialog 
Java :: regex pattern for date validation 
Java :: how to add an image to a gui in java windowbuilder 
Java :: java set from string array 
Java :: java list distinct by object attribute 
ADD CONTENT
Topic
Content
Source link
Name
2+7 =