Closed burhanrashid52 closed 7 years ago
Does your activity override onBackPressed and feed the event to your router?
@Override
public void onBackPressed() {
if (!router.handleBack()) {
super.onBackPressed();
}
}
Yes..
One of your child controllers must be handling the back button event. Without any code I can't tell what the issue is though.
I'm not sure if it's exactly what @burhanrashid52 is experiencing, but I was having a similar issue which I reproduced here.
I have a single home controller, which sets the root controller on a single child router and calls the restore and save on that child router to preserve the views. Now when I push another child controller on top of a root controller, I can press the back button to pop it off. But if I were to leave that root and come back while the child controller were still pushed, the back button now closes the activity instead of popping the child controller. Am I doing something wrong?
The saveInstanceState
and restoreInstanceState
methods weren't really meant to be used by developers. They should have probably been package-private, but I guess it's too late for that now. I'm curious why you're doing it that way? What problem does this solve?
I'm using the BottomNavigationView and modeled my ControllerManager similarly to the ViewPager example you made, where there is one host controller (my HomeController) and one child router that has its root controller swapped out. Those controllers can then also have controllers pushed onto them as well, but I still want to have the option to navigate to one of my other root controllers and preserve the state of that pushed stack.
Is this the correct approach or would you recommend another solution?
When we apply pushController on
onCreateView()
oronAttach(View view)
with this code:getRouter().pushController(RouterTransaction.with(new Home3Controller()));
so at that time when we click on back button its does not pop up the view but its works fine when we put this on button click event manually