title: Ionic 4 android hardware back button and toolbar back not working in same flow
body: <p>I came across an issue in my android app which i have developed using ionic 4.
  My scenario is if i navigate through pages and came back using toolbar back button and again navigate to another pages and came back using android hardware back button then the pages i navigated back using toolbar back button shows in middle while using hardware back button.</p>
  
  <p>Page A->B->C and then on toolbar back button C->B->A</p>
  
  <p>Again page navigate A->D->E and then using hardware back button page navigate E->D->B->C->B->A</p>
  
  <p>Unable to maintain state.</p>
  
  <p>My Code</p>
  
  <p>In app.component.ts constructor</p>
  
  <pre><code>this.router.events.subscribe(event =&gt; {
        const url = this.router.url //current url
        if (event instanceof NavigationEnd) {
          const isCurrentUrlSaved = this.navLinksArray.find((item) =&gt; { return item === url });
          if (!isCurrentUrlSaved) this.navLinksArray.push(url);
        }
      }); 
  
  
  ngAfterViewInit() {
  
      this.backButtonSubscription = this.platform.backButton.subscribe(() =&gt; {
            if (this.router.url === '/tabs/home') {
              navigator['app'].exitApp();
            } else {
              if (this.navLinksArray.length &gt; 1) {
                this.navLinksArray.pop();
                const index = this.navLinksArray.length - 1;
                const url = this.navLinksArray[index];
                this.navCtrl.navigateBack(url);
              }
            }
          });
        }
  }
  </code></pre>
  
  <p>Thanks in advance. </p>