Is there a way to minimize the app to the background with a button inside the app?
Some apps do that when you press the exit option. They don't close but put the app in the background...
I want to do that with my Ionic app or with a cordova way.
Is there a way to minimize the app to the background with a button inside the app?
Some apps do that when you press the exit option. They don't close but put the app in the background...
I want to do that with my Ionic app or with a cordova way.
I just created a plugin called "AppMinimize" for cordova (only for Android devices) that does what you want. I hope it helps you.
cordova plugin add https://github.com/tomloprod/cordova-plugin-appminimize.git
window.plugins.appMinimize.minimize();
$ionicPlatform.registerBackButtonAction(function (event) {
event.preventDefault();
window.plugins.appMinimize.minimize();
}, 100);
if you are using ionic-3, solution from docs works like charm
Install the Cordova and Ionic Native plugins:
$ ionic cordova plugin add cordova-plugin-appminimize
$ npm install --save @ionic-native/app-minimize
Add this plugin to your app's module
Usage
import { Platfrom } from 'ionic-angular';
import { AppMinimize } from '@ionic-native/app-minimize';
constructor(private platform: Platform, private appMinimize: AppMinimize) { }
...
this.platform.registerBackButtonAction(() => {
this.appMinimize.minimize();
});
You can do so using intent logic. Here is the android code you can find there
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);
Let you do the rest to translate it in cordova/ionic ( don't know that framework)