When pressing backbutton in android I want the app the be close and paused, not terminated, as when you press the homebutton. Is it any way to do this in cordova (ionic)? Like what method/event is "homebutton" firing?
Thanks
When pressing backbutton in android I want the app the be close and paused, not terminated, as when you press the homebutton. Is it any way to do this in cordova (ionic)? Like what method/event is "homebutton" firing?
Thanks
May be its not too late. Actually I was also trying the same. I didn't get any solution. So I have created one plugin for it. Please refer this link Cordova Plugin - Back As Home
Add Plugin
cordova plugin add https://github.com/amitsinha559/cordova-plugin-back-as-home.git
Add this codes in .run
if you want to work back as home button
$ionicPlatform.registerBackButtonAction(function(e){
backAsHome.trigger(function(){
console.log("Success");
}, function(){
console.log("Error");
});
e.preventDefault();
},101);
Note: Right now I don't have device. I have not tested the above code.
If you want to use in some button action
$scope.someButton = function() {
backAsHome.trigger(function(){
console.log("Success");
}, function(){
console.log("Error");
});
}
Hope it will help :). Please let me know if you are facing any issue.
$ionicPlatform.registerBackButtonAction(function () {
if ($state.current.name == "signIn"){
navigator.app.exitApp();
} else {
navigator.app.backHistory();
}
}, 100);
for reference please check the blogspot under register back button action and reply me if you have any queries