I have problem with the context in the mosulo that I call from native react
public class PaymentModule extends ReactContextBaseJavaModule { public PaymentModule(ReactApplicationContext context) { super(context);} @Override public String getName() { return "PaymentModule";} @ReactMethod public void paymentEvent() { System.out.println("Ya ejecute"); Mainprocess mainprocess = new Mainprocess(); mainprocess.getData(); } private Intent buildPaymentRequestIntent() { String externalPaymentId = "<posPaymentId>"; // should be unique for each request long amount = 1000; Context contextt = this; PaymentRequestIntentBuilder builder = new PaymentRequestIntentBuilder(externalPaymentId, amount); return builder.build(contextt); } }
Try to fix it by creating another java class and calling it from Paymentmodule
public void paymentEvent() { System.out.println("Ya ejecute"); Mainprocess mainprocess = new Mainprocess(); mainprocess.getData(); }
public class Mainprocess extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public void getData(){ runOnUiThread(new Runnable() { @Override public void run() { System.out.println("Desde el proceso"); // Intent intent = buildPaymentRequestIntent(); } }); } private Intent buildPaymentRequestIntent() { String externalPaymentId = "<posPaymentId>"; // should be unique for each request long amount = 1000; Context context = this; PaymentRequestIntentBuilder builder = new PaymentRequestIntentBuilder(externalPaymentId, amount); return builder.build(context); } }
but when executing the ract native application and launching that function it generates this error
Agradesco su ayuda