├── www └── AppMinimize.js ├── package.json ├── src └── android │ └── AppMinimize.java ├── plugin.xml ├── LICENSE.md └── README.MD /www/AppMinimize.js: -------------------------------------------------------------------------------- 1 | var appMinimize = { 2 | minimize: function (successCallback, errorCallback) { 3 | cordova.exec(successCallback, errorCallback, 'AppMinimize', 'minimize', []); 4 | } 5 | } 6 | 7 | if (!window.plugins) { window.plugins = {}; } 8 | 9 | window.plugins.appMinimize = appMinimize; 10 | return window.plugins.appMinimize; 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cordova-plugin-appminimize", 3 | "version": "1.0.1", 4 | "description": "This is a cordova plugin to minimizes the application in android devices.", 5 | "cordova": { 6 | "id": "cordova-plugin-appminimize", 7 | "platforms": [ 8 | "android" 9 | ] 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/tomloprod/cordova-plugin-appminimize" 14 | }, 15 | "keywords": [ 16 | "cordova", 17 | "ionic", 18 | "minimize", 19 | "android" 20 | ], 21 | "scripts": { 22 | "test": "echo \"Error: no test specified\" && exit 1" 23 | }, 24 | "author": "tomloprod", 25 | "license": "MIT" 26 | } 27 | -------------------------------------------------------------------------------- /src/android/AppMinimize.java: -------------------------------------------------------------------------------- 1 | package tomloprod; 2 | 3 | import org.apache.cordova.CallbackContext; 4 | import org.apache.cordova.CordovaPlugin; 5 | import org.json.JSONArray; 6 | import org.json.JSONException; 7 | import android.content.Intent; 8 | 9 | public class AppMinimize extends CordovaPlugin { 10 | 11 | @Override 12 | public boolean execute(String action, JSONArray data, CallbackContext callbackContext) throws JSONException { 13 | 14 | if (action.equals("minimize")) { 15 | Intent startMain = new Intent(Intent.ACTION_MAIN); 16 | startMain.addCategory(Intent.CATEGORY_HOME); 17 | startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 18 | this.cordova.getActivity().startActivity(startMain); 19 | callbackContext.success(1); 20 | } 21 | 22 | 23 | return false; 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AppMinimize 6 | This is a cordova plugin to minimizes the application in android devices 7 | MIT 8 | cordova, ionic, minimize, android 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Tomás López 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # cordova-plugin-appminimize [![License](https://img.shields.io/github/license/tomloprod/cordova-plugin-appminimize.svg)](http://www.opensource.org/licenses/mit-license.php) 2 | 3 | **AppMinimize** is a cordova plugin to minimize the application in android devices 4 | 5 | ## Supported Platforms 6 | 7 | - Android 8 | 9 | ## Installation 10 | 11 | Cordova: 12 | 13 | cordova plugin add cordova-plugin-appminimize 14 | 15 | ## Usage 16 | 17 | This plugin exports an object with one method called "minimize": 18 | 19 | ```javascript 20 | window.plugins.appMinimize.minimize(); 21 | ``` 22 | 23 | ## Ionic Example 24 | 25 | In this example the application is minimized by pressing the back button 26 | 27 | ```javascript 28 | $ionicPlatform.registerBackButtonAction(function (event) { 29 | event.preventDefault(); 30 | window.plugins.appMinimize.minimize(); 31 | }, 100); 32 | ``` 33 | 34 | 35 | ## Ionic Example 36 | 37 | In this example the application is minimized by pressing the back button 38 | 39 | ```bash 40 | ionic cordova plugin add cordova-plugin-appminimize 41 | npm install --save @ionic-native/app-minimize 42 | ``` 43 | 44 | ```typescript 45 | import { AppMinimize } from '@ionic-native/app-minimize'; 46 | 47 | ... 48 | 49 | constructor(private appMinimize: AppMinimize) { } 50 | 51 | ... 52 | 53 | this.platform.registerBackButtonAction(() => { 54 | this.appMinimize.minimize(); 55 | }); 56 | ``` 57 | --------------------------------------------------------------------------------