STAR-ZERO / navigation-keep-fragment-sample

392 stars 63 forks source link

Keep Mapbox alive #3

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi there,

I have a DashboardFragment containing Mapbox Mapview: https://docs.mapbox.com/android/maps/overview/

From the DashboardFragment the user can navigate to MenuFragment(and further) and go back. My problem is that when I return to the DashboardFragment, the DashboardFragment is loaded (including the Mapbox Mapview) again. I tried using your solution but it doesn't work for me. I did everything you did except I don't use DataBindingUtil and BottomNavigationView.

I basically want that DashboardFragment is created once and when navigating to another fragment, it should stay alive. Is this what your solution is trying to achieve or can you point me in the right direction?

STAR-ZERO commented 5 years ago

When navigate to another fragment, fragment is alive. But its lifecycle starts from onCreateView. I guess you are reloading Mapbox. Maybe you should prevent reloading Mapbox.

I don't know about Mapbox, so I can't answer clearly. 🙇