androidx.biometric.compose
Top-level functions summary
AuthenticationResultLauncher |
@ComposableReturns an |
AuthenticationResultLauncher |
@ComposableReturns an |
Top-level functions
rememberAuthenticationLauncher
@Composable
fun rememberAuthenticationLauncher(
resultCallback: AuthenticationResultCallback
): AuthenticationResultLauncher
Returns an AuthenticationResultLauncher that can be used to initiate authentication.
A successful or error result will be delivered to AuthenticationResultCallback.onAuthResult and (one or more) failures will be delivered to AuthenticationResultCallback.onAuthAttemptFailed, which is set by resultCallback. The callback will be executed on the main thread.
import androidx.biometric.AuthenticationRequest import androidx.biometric.AuthenticationRequest.Companion.biometricRequest import androidx.biometric.compose.rememberAuthenticationLauncher import androidx.compose.foundation.layout.Column import androidx.compose.material3.Button import androidx.compose.material3.Text import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable var result by rememberSaveable { mutableStateOf("") } val launcher = rememberAuthenticationLauncher { authResult -> result = authResult.toText() } Column { Button( onClick = { launcher.launch( biometricRequest( title = "test", authFallback = AuthenticationRequest.Biometric.Fallback.DeviceCredential, ) { // Optionally set the other configurations. setSubtitle(), setContent(), etc } ) } ) { Text(text = "Start Authentication") } Text(text = "Result: $result") }
| See also | |
|---|---|
rememberAuthenticationLauncher |
(Executor, AuthenticationResultCallback) |
rememberAuthenticationLauncher
@Composable
fun rememberAuthenticationLauncher(
callbackExecutor: Executor,
resultCallback: AuthenticationResultCallback
): AuthenticationResultLauncher
Returns an AuthenticationResultLauncher that can be used to initiate authentication.
A successful or error result will be delivered to AuthenticationResultCallback.onAuthResult and (one or more) failures will be delivered to AuthenticationResultCallback.onAuthAttemptFailed, which is set by resultCallback. The callback will be executed on the thread provided by the callbackExecutor.
import androidx.biometric.AuthenticationRequest import androidx.biometric.AuthenticationRequest.Companion.biometricRequest import androidx.biometric.compose.rememberAuthenticationLauncher import androidx.compose.foundation.layout.Column import androidx.compose.material3.Button import androidx.compose.material3.Text import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.saveable.rememberSaveable var result by rememberSaveable { mutableStateOf("") } val launcher = rememberAuthenticationLauncher { authResult -> result = authResult.toText() } Column { Button( onClick = { launcher.launch( biometricRequest( title = "test", authFallback = AuthenticationRequest.Biometric.Fallback.DeviceCredential, ) { // Optionally set the other configurations. setSubtitle(), setContent(), etc } ) } ) { Text(text = "Start Authentication") } Text(text = "Result: $result") }
| See also | |
|---|---|
rememberAuthenticationLauncher |
(AuthenticationResultCallback) |