React Native: Android activity go back

匿名 (未验证) 提交于 2019-12-03 03:03:02

问题:

I implemented android native module from Bambora SDK and displayed its native view(activity) by getCurrentActivity().startActivity(intent);

It works like a charm but finish() makes whole app quit instead of going back. Here are some of my codes.

public class ToastModule extends ReactContextBaseJavaModule {     @ReactMethod     // Calling module function from ReactJS code and works well     public void goToRegisterCardView(Callback callback) {         Intent intent = new Intent(getCurrentActivity(), NativeCardRegistrationActivity.class);         getCurrentActivity().startActivity(intent); //start Activity successfully     }     ... }  public class NativeCardRegistrationActivity extends AppCompatActivity implements ICardRegistrationCallback {     @Override     public void onRegistrationSuccess(CreditCard creditCard) {         finish();// Exit whole app instead of going back.     }     ... } 

So I'm sure it's not a reason from Bambora SDK and finish() kills NativeCardRegistrationActivity. The whole app is killed because there is no activity in Activity Stack. Because I'm not familiar with Java code, I'm not able to figure out what the reason is here.

Please let me know what's wrong and how I can go back to original react-native activity.

**Update

Here is my MainApplication.java codes

public class MainApplication extends MultiDexApplication {    // Needed for `react-native link`   public List<ReactPackage> getPackages() {     return Arrays.<ReactPackage>asList( //      new MainReactPackage(),       new AnExampleReactPackage(this)     );   } } 

Currently, I commented new MainReactPackage() for temporarily and it doesn't occur error, but if I remove the comment to enable new MainReactPackage() then, I can see error with red background.

Please check this. ReactNative: Android Native Module

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!