I have an application in React Native, which uses a native module designed by me, in this module I process a payment and I need to use getCurrentActivity(). The method looks like this:
@ReactMethod
public void createOpenpayCard(){
Activity activity = getCurrentActivity();
String deviceIdString = openpay.getDeviceCollectorDefaultImpl().setup(activity);
}
The problem is that after executing this, the webview that I have in the same component, throws the following error:
calling view methods on another thread than the ui thread.
If I comment out the line of code in the ReactMethod that uses getCurrentActivity, the web view works perfectly.
My web view component looks like this:
import WebView from 'react-native-webview';
export default function WebView3D(props) {
return (
<WebView
source={{ uri: 'https://infinite.red' }}
style={{ marginTop: 20 }}
/>
)
}
Any ideas how I can fix this?