Skip to content

Cannot go back to react-native from android native activity #15150

@AlexanderIgnacz

Description

@AlexanderIgnacz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions