Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
AlexanderIgnacz opened this issue Jul 22, 2017 · 6 comments
Closed

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

AlexanderIgnacz opened this issue Jul 22, 2017 · 6 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@AlexanderIgnacz
Copy link

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.

@joarwilk
Copy link

Would you mind open-sourcing this? I know a lot of other people (me included) are building the same thing, might be better to do it together instead.

@AlexanderIgnacz
Copy link
Author

Which source do you mean? For Bambora? If so, I can produce new project with Bambora but unfortunately, I'm not able to share the source now because it is on-developing. 🙏

@joarwilk
Copy link

Yeah, like a react-native-bambora package. Dont worry if its still under development, if you open source it you can probably finish faster since more people can help build it.

@hey99xx
Copy link

hey99xx commented Aug 1, 2017

There isn't anything obvious in your code.

Can you share how you've declared both your standard RN activity and the NativeCardRegistrationActivity in your AndroidManifest.xml? Maybe you're accidentally configuring your activities to clear the history or reset the stack after NativeCardRegistrationActivity is opened. Or you are using some additional flags in your intent that's not shown in your sample code.

You can also try adb to dump your activity stack and see if your RN activity is gone after your open your NativeCardRegistrationActivity.

@AlexanderIgnacz
Copy link
Author

Sorry, it was my own fault. I tested with emulators and it worked fine. So I checked the device developer options and found that "Do not keep activities" is enabled.
Disabling it solved my problem.
I'm now closing this issue and thanks very much for reaching.

@hey99xx
Copy link

hey99xx commented Aug 1, 2017

FYI That does not sound right. You should have been able to recreate the activity when you navigated back. "Do not keep activities" is not intended to kill the activities in the stack permanently, it is to destroy them to make sure you can recreate with the bundle arguments, saved instance state etc. https://stackoverflow.com/questions/22400859/dont-keep-activities-what-is-it-for

@facebook facebook locked as resolved and limited conversation to collaborators Aug 1, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Aug 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants