1

I am creating new android application using android architecture components.

Here the scenario is, I have created one ( no other activities ) main activity where I have put NavHostFragment along with drawerlayout. Now I have fragment for splashscreen, where I made toolbar hidden, and everything works fine.

Now, when after 5 seconds I call other fragment using navigationcontroller, in new fragment(home fragment), instead of showing icon to open drawer, it shows back button there. And on click of back button icon, it loads splashscreen again.

Any suggestions ?

Jay Vyas
  • 2,674
  • 5
  • 27
  • 58
  • The best practice is to use a splash AppTheme https://stackoverflow.com/a/51190419/1268507 – Alex Nov 21 '18 at 07:10

1 Answers1

1

This happens because the navigation graph adds fragments to backstack and when you press the back button that pops backstack and navigates to previously fragment.

I suggest you use an activity as the splash screen for better control your stack and backstack and make it as the launcher and finish it after 5 seconds then start the main activity.

Take a look Principles of Navigation

Hamed Nabizadeh
  • 527
  • 4
  • 9