# Hardware back button and navigation management on Android with Ionic 4

**URL:** <https://forum.ionicframework.com/t/hardware-back-button-and-navigation-management-on-android-with-ionic-4/151187>\
**Category:** Ionic Framework\
**Created:** [December 24, 2018, 9:33am UTC](https://forum.ionicframework.com/t/hardware-back-button-and-navigation-management-on-android-with-ionic-4/151187 "2018-12-24T09:33:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fifth](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@fifth](https://forum.ionicframework.com/u/fifth)\
**Post date:** [December 24, 2018, 9:33am UTC](https://forum.ionicframework.com/t/hardware-back-button-and-navigation-management-on-android-with-ionic-4/151187/1 "2018-12-24T09:33:57Z")

</div>

I’ve been using Ionic 3 more than 1 year and I started using v4 now. However I’m confused with current navigation management, there’s no ‘root’, there’s no navigation stack, even the simple NavController’s gone as well ☹

First I created a tabs layout from official starter project, then added a simple button in tab2. By clicking on that button, it can go to another page1. And I called navController.navigateRoot(’’) when dismissed the page1.

However, on Android, I just found that the hardware/virtual back button behaved very close to a browser style, every “back” just went back to earlier history. For example, if you first go tab1 -\> tab3-\> tab2 -\> page1 -\> tabs, then keep clicking on back button, it would give you tabs -\> page1 -\> tab2 -\> tab3 -\> tab1.

It’s wired for a mobile app. I found nothing to help setting a real root like previous v3. I really need tabs to be a root and some similar popToRoot() to dump current navigation stack.

Could anyone give suggestion on how to manage navigation on v4? Thanks

---

<div class="post-metadata">

**Author:** ![brickolicious](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/brickolicious/32/99633_2.png) [@brickolicious](https://forum.ionicframework.com/u/brickolicious)\
**Post date:** [January 2, 2019, 12:19am UTC](https://forum.ionicframework.com/t/hardware-back-button-and-navigation-management-on-android-with-ionic-4/151187/2 "2019-01-02T00:19:15Z")

</div>

In Ionic 4 i ditched NavController class for the vanilla Angular router

I struggled with the same situation where i could navigate back and it it would pass my “root pages” and keep naving back.

As a make shift solution i found that i can prevent this behavior by adding the additional param `replaceUrl` when navigating to what I deem a root page.

> this.router.navigate([page], { replaceUrl: true })

the variable `page ` above, being a string coming from the page selected in my menu for example `/dashboard` or `/profile`

This helped prevent, naving back through my entire nav history when using the android hardware button.

If you come up with a better solution please let me know

---

<div class="post-metadata">

**Author:** ![fifth](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@fifth](https://forum.ionicframework.com/u/fifth)\
**Post date:** [January 4, 2019, 7:14am UTC](https://forum.ionicframework.com/t/hardware-back-button-and-navigation-management-on-android-with-ionic-4/151187/3 "2019-01-04T07:14:22Z")

</div>

Thanks for reply. `replaceUrl` at least worked around in some cases. On mobile, we’re building SPA, a stack like navigation is much simpler than Angular original router, don’t understand why Ionic 4 dropped previous NavController, hopefully they can add it back

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:03pm UTC](https://forum.ionicframework.com/t/hardware-back-button-and-navigation-management-on-android-with-ionic-4/151187/4 "2021-07-19T21:03:25Z")

</div>

Closed on July 19, 2021, 9:03pm UTC


