Control the android back button navigation


#1

Hi,

I tried many different solutions to avoid the android back button
goes to the previous view, but without positive results.

I’ve a “start” state and, when the job is done, the application
goes to a “home” state through the $state.go function.

I tried:

  • registering a callback back action using $ionicPlatform
  • using the nav-clear directive on the next view
  • using $ionicHistory.clearHistory
  • using $ionicHistory.currentView($ionicHistory.backView())
  • using $state.go(“home”, {}, {location: “replace”})
  • using $state.go(“home”, {}, {location: “replace”, notify: false})
  • using $ionicHistory.nextViewOptions({disableBack: true})

What can I do to solve the problem?

Thanks in advance


#2

use:

$ionicPlatform.registerBackButtonAction(function () {
     // do something
     
 }, 100);

http://ionicframework.com/docs/api/service/$ionicPlatform/


#3

I tried already this solution but doesn’t works.
But after many and many and many tests,
I tried with priority 101 instead of 100 and… It works correctly. :sweat_smile:

Thanks anyway.