Skip to content Skip to sidebar Skip to footer

Onactivityresult() Is Deprecated In Android Fragment

I search on google for onactivityresult() is deprecated. but my problem was not solve . here is the code of fragment @Override public void onRequestPermissionsResult(int reque

Solution 1:

Kotlin - Below code instead of startActivityForResult deprecation this method gives the result itself and returns a value.

val resultLauncher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
    when (result.resultCode) {
        Activity.RESULT_OK -> {
            // logic
        }
        else -> {
            // logic
        }
    }
}

Post a Comment for "Onactivityresult() Is Deprecated In Android Fragment"