How put app in background (Minimize)?

How i can put the app in background mode when the back button (hardware) is tapped in Login view?

The login view is the first view, when back button is pressed this return for login view again.

3 Likes

I have the same problem, please help :frowning:

2 Likes

Hi, I have the same problem, too.

I tried the plugin cordova-plugin-background-mode, but it doesn’t work.
When I press the home button, the plugin works precisely, the onactive function called.
When I press the back button, the plugin works wrongly, the onactive function called and the ondeactive function called immediately.

Expecting for help. Think you.

I just created a plugin called “AppMinimize” for cordova (only for Android devices) that does what you want. I hope it helps you.

Installation:

cordova plugin add https://github.com/tomloprod/cordova-plugin-appminimize.git

Usage:

window.plugins.appMinimize.minimize();

Example: Minimize app by pressing back button:

$ionicPlatform.registerBackButtonAction(function (event) {
    event.preventDefault();
    window.plugins.appMinimize.minimize();
}, 100);

###Github:

2 Likes

Hi! I installed your plugin but it doesn’t work:
It’s my code in app.js and i tested it on android device:

.run(function($ionicPlatform, $ionicPopup, $state) {
  $ionicPlatform.registerBackButtonAction(function (event) {
    if($state.current.name=="menu.dashboard"){
      alert('it is dashboard');//it works
      window.plugins.appMinimize.minimize();
    }
    else {
      navigator.app.backHistory();
    }
  }, 100);
})

Do you have any solution?

Hi,

What is your device? Can you check your plugin list to make sure that its installed?

 cordova plugin ls

You can try with:

 cordova plugin save

If still with problems, please open an “issue” in github

Regards,

Your plugin in the list of cordova’s plugins.
And i ran
cordova plugin save
And compiled and installed my app again.
But it doesn’t work again

My device has android 5.1

Besides your installation does’t work, i installed plugin manually.
Maybe it is a problem and i heed help with installation

I used in production in many devices and works well… and I don’t understand why the installation doesn’t work for you.

I’ts pretty simple:

 cordova plugin add https://github.com/tomloprod/cordova-plugin-appminimize.git

And use the plugin… What is the error you get?

Sorry!!!
Your plugin is working and thank you!

I have problem with git and environment

1 Like

it’s work on ionic 2 ?