adyen-android
adyen-android copied to clipboard
GooglePayComponent forces us to use the deprecated onActivityResult
We haven't used the deprecated onActivityResult in our app in some time, we use registerForActivityResult with ActivityResultContracts as Google recommends. Now when we added the Adyen SDK in order to support GooglePay the documentation made it pretty clear that onActivityResult needs to be used. The problem is that when onActivityResult is overridden on activity level, all existing activity result handling in our fragments stop working:
private val launcher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
// Result callbacks never called
}
private fun openPaymentOption() {
launcher.launch(intent)
}
Digging into the SDK it is clear that you are aware of this problem, this is from com.adyen.checkout.googlepay.GooglePayComponent lines 91-92
// TODO this forces us to use the deprecated onActivityResult. Look into alternatives when/if Google provides any later.
AutoResolveHelper.resolveTask(paymentsClient.loadPaymentData(paymentDataRequest), activity, requestCode);
SDK version: com.adyen.checkout:googlepay:4.7.1
Any progress with this? It would be very tedious from our side to revert back to using deprecated functions.
Hi Toni, thanks for reaching out! Unfortunately we're as frustrated by this as you are, as this is the only place in our whole codebase where we still need to use the deprecated onActivityResult.
But the Google docs do not provide an alternative as you can see here and here and there are numerous questions about this to Google but they're all unanswered.
Thanks for the quick reply!
Definitely frustrating, but I do understand that we are in the same situation :(
Hi @tonihuotari and @jreij.
We wanted to let you know that this is in our radar and we are looking into it.
In the meantime, there's a way to use the new Activity Result API with the Google Pay API, although it comes at the cost of losing the abstraction provided by the AutoResolveHelper -> see the proposed commit in the Google Pay sample app repo.
Our recommendation is to hold on until the update to the Google Pay SDK is published. If you prefer not to wait, you can use the solution above, keeping in mind that this will likely incur in a later change when our API is updated. Hope this helps.