I struggle to understand context activity inside Capacitor plugin.
Inside one of the plugin methods, ( I stripped the code just to show the problem)
public class GooglePayPlugin extends Plugin {
private Activity activity;
public void init(PluginCall call){
activity = getActivity();
googlePayClient.requestPayment(activity, googlePayRequest, (success, error) -> {
if (error != null) {
// handle error
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
googlePayClient.onActivityResult(resultCode, data, (paymentMethodNonce, error) -> {
// send paymentMethodNonce.getString() to your server
});
}
}
How to get activity, that will call onActivityResult inside the plugin ?
In example above I get onActivityResult response, but it's inside MainActivity so I don't have access to plugin properties.