chansek
03/17/2022, 11:06 AM@Composable
fun Payment(
price: Double,
onResult: (Int, PaymentResponse) -> Unit
) {
val launcher = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) {
onResult(RC_PAY, appNotFoundError ?: handlePaymentResult(it.data))
}
launcher.launch(preparePaymentIntent(price))
}
How do I handle the exception caused by launcher.launch
when there is not Acitivity found to handle the Intent
passed to launch
?Filip Wiesner
03/17/2022, 11:13 AMtry { ... } catch(e: ActivityNotFoundException) { ... }
like you would normally do. There is nothing compose specific.chansek
03/17/2022, 11:26 AMrememberLauncherForActivityResult
This gets a callback even though there is no activity.Filip Wiesner
03/17/2022, 11:37 AMresultCode
to know if it was successful