Android back button not detected


#1

Hi,

I am trying to let my Ionic app respond to the Android back button. No matter what I do, place it like this in app.run or in my controller, it somehow misses the backbutton event. The “go back in history” action of the button is performed, so the hardware works. Am I missing something here? Or is there another way to respond to the back button? Addressing Cordova directly?

var app = angular.module('starter', ['ionic']);

app.run(function($ionicPlatform) {
	
  $ionicPlatform.ready(function() {
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
  
  $ionicPlatform.onHardwareBackButton(function(event) {
	     event.preventDefault();
	     event.stopPropagation();
	     alert('Detected!');
  });
  
});

Thanks, Ton


#2

Take a look at this thread and post:

enter link description here