```@Composable fun Payment( price: Double, ...
# compose
c
Copy code
@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
?
f
Using
try { ... } catch(e: ActivityNotFoundException) { ... }
like you would normally do. There is nothing compose specific.
☝🏼 1
☝️ 1
c
Copy code
rememberLauncherForActivityResult
This gets a callback even though there is no activity.
f
You should look at
resultCode
to know if it was successful