Closed
Description
The Android Developers documentation recommends using the Activity Result APIs instead of relying on intents for launching activities for results. Using the new APIs would enable a nicer development experience. Take the following as an example:
class FirebaseAuthUIActivityResult: ActivityResultContract<AuthUI.SignInIntentBuilder, IdpResponse>() { ... }
This API could be used like this:
val firebaseLogin = registerForActivityResult(FirebaseAuthUIActivityResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
...
}
}
firebaseLogin.launch(
AuthUI.getInstance().createSignInIntentBuilder()
.setAvailableProviders(authenticationMethods)
.setTheme(R.style.SignInTheme)
.setAuthMethodPickerLayout(signInLayout)
)
By using a contract with types, this is safer for the end-user. More importantly, it enables future usage from Jetpack Compose.
I'd be happy to contribute here if we can scope it a bit :)
Let me know what you think!