Nouvelle API de résultats Android et comment l’utiliser pour rendre votre code plus propre
startActivityForResult(ActivityB.newIntent(this), ACTIVITY_A_REQUEST_CODE)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { ... }
val startForResult = prepareCall(ActivityResultContracts.StartActivityForResult()) { result: ActivityResult -> ... }
private lateinit var startForResult : ActivityResultLauncheroverride fun onCreate(owner: LifecycleOwner) { startForResult = registry.registerActivityResultCallback(START_FOR_RESULT_KEY, owner, ActivityResultContracts.StartActivityForResult(), ActivityResultCallback { result -> ... }
}
Lectures complémentaires