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

EmptyStackException #41

Open
Fanom2813 opened this issue Apr 27, 2022 · 3 comments
Open

EmptyStackException #41

Fanom2813 opened this issue Apr 27, 2022 · 3 comments
Labels
question Further information is requested

Comments

@Fanom2813
Copy link

Hello guys, i have this problem where by sometimes if i leave the app for a moment and it goes to sleep then i try navigate through the app i get this error :

java.util.EmptyStackException
at com.smartcabspro.user.MainActivity.onBackPressed(:4)

what could be the problem ?

@MertNYuksel
Copy link
Member

This seems weird. What is your onBackPressed function look like? Do you use navigator.canGoBack function just like in samples? If you do, can you send us a sample that reproduce this crash?
https://github.com/Trendyol/medusa/wiki/Basic-Usage

@bilgehankalkan bilgehankalkan added the question Further information is requested label Apr 27, 2022
@Fanom2813
Copy link
Author

i have followed the exact same thing as the tutorial

MultipleStackNavigator multipleStackNavigator;
    private List<Function0<Fragment>> rootsFragmentProvider = Arrays
            .asList(
                    new Function0<Fragment>() {
                        @Override
                        public Fragment invoke() {
                            return new HomeFragment();
                        }
                    },
...
@Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState)

       multipleStackNavigator = new MultipleStackNavigator(
               getSupportFragmentManager(),
               R.id.fragment_host,
               rootsFragmentProvider,
               this,
               new NavigatorConfiguration(0, true, NavigatorTransaction.ATTACH_DETACH),
               null);

       multipleStackNavigator.initialize(savedInstanceState);
@Override
    public void onBackPressed() {
        if (multipleStackNavigator.canGoBack()) {
            multipleStackNavigator.goBack();
        } else {
            super.onBackPressed();
        }
    }

this error happens to me if i let the phone go to sleep mode when the app is running , then after sometime i start using the app again

@MertNYuksel
Copy link
Member

MertNYuksel commented Apr 28, 2022

It feels like this might related to activity recreation. Did you also override onSaveInstanceState and call navigator.onSaveInstanceState in it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants