Initial commit
This commit is contained in:
25
plugins/cordova.custom.plugins.exitapp/README.md
Normal file
25
plugins/cordova.custom.plugins.exitapp/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
cordova-plugin-exitapp
|
||||
----------------------
|
||||
|
||||
This plugin adds the ability to programmatically close an app on Android or Windows Phone 8.
|
||||
|
||||
## Installation
|
||||
|
||||
Plugin id: cordova.custom.plugins.exitapp
|
||||
|
||||
To install this plugin, follow the [Command-line Interface Guide](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface).
|
||||
|
||||
If you are not using the Cordova Command-line Interface, follow [Using Plugman to Manage Plugins](http://cordova.apache.org/docs/en/edge/plugin_ref_plugman.md.html).
|
||||
|
||||
## Usage
|
||||
|
||||
confirmed = function(buttonIndex) {
|
||||
if(buttonIndex == 1) {
|
||||
console.log("navigator.app.exitApp");
|
||||
navigator.app.exitApp();
|
||||
}
|
||||
}
|
||||
|
||||
onTouch = function() {
|
||||
navigator.notification.confirm('', confirmed, 'Exit?');
|
||||
}
|
||||
30
plugins/cordova.custom.plugins.exitapp/package.json
Normal file
30
plugins/cordova.custom.plugins.exitapp/package.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "cordova-plugin-exitapp",
|
||||
"version": "1.0.0",
|
||||
"description": "Implements navigator.app.exitApp on WP8, Android",
|
||||
"cordova": {
|
||||
"id": "cordova.custom.plugins.exitapp",
|
||||
"platforms": [
|
||||
"wp8",
|
||||
"android"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/rakesh-walisheter/cordova-plugin-exitapp.git"
|
||||
},
|
||||
"keywords": [
|
||||
"cordova",
|
||||
"exit",
|
||||
"terminate",
|
||||
"ecosystem:cordova",
|
||||
"cordova-wp8",
|
||||
"cordova-android"
|
||||
],
|
||||
"author": "Rakesh Walisheter",
|
||||
"license": "Apache 2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/rakesh-walisheter/cordova-plugin-exitapp/issues"
|
||||
},
|
||||
"homepage": "https://github.com/rakesh-walisheter/cordova-plugin-exitapp#readme"
|
||||
}
|
||||
35
plugins/cordova.custom.plugins.exitapp/plugin.xml
Normal file
35
plugins/cordova.custom.plugins.exitapp/plugin.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova.custom.plugins.exitapp"
|
||||
version="1.0.0">
|
||||
|
||||
<name>ExitApp</name>
|
||||
<description>Implements navigator.app.exitApp on WP8, Android</description>
|
||||
<license>Apache 2.0</license>
|
||||
<keywords>cordova,terminate</keywords>
|
||||
|
||||
<js-module src="www/ExitApp.js" name="exitApp">
|
||||
<merges target="navigator.app" />
|
||||
</js-module>
|
||||
|
||||
<!-- wp8 -->
|
||||
<platform name="wp8">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="ExitApp">
|
||||
<param name="wp-package" value="ExitApp" />
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/wp/ExitApp.cs" />
|
||||
</platform>
|
||||
|
||||
<!-- android -->
|
||||
<platform name="android">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="ExitApp">
|
||||
<param name="android-package" value="cordova.custom.plugins.exitapp.ExitApp" />
|
||||
</feature>
|
||||
</config-file>
|
||||
<source-file src="src/android/ExitApp.java" target-dir="src/cordova/custom/plugins/exitapp" />
|
||||
</platform>
|
||||
</plugin>
|
||||
@@ -0,0 +1,34 @@
|
||||
package cordova.custom.plugins.exitapp;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaInterface;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.PluginResult;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
public class ExitApp extends CordovaPlugin {
|
||||
protected void pluginInitialize() {}
|
||||
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
/*
|
||||
* Finishes the activity provided by CordovaInterface.
|
||||
*/
|
||||
|
||||
if (action.equals("exitApp")) {
|
||||
try {
|
||||
Activity activity = this.cordova.getActivity();
|
||||
activity.finish();
|
||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 0));
|
||||
} catch (Exception e) {
|
||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, 1));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
20
plugins/cordova.custom.plugins.exitapp/src/wp/ExitApp.cs
Normal file
20
plugins/cordova.custom.plugins.exitapp/src/wp/ExitApp.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WPCordovaClassLib.Cordova;
|
||||
using WPCordovaClassLib.Cordova.Commands;
|
||||
using WPCordovaClassLib.Cordova.JSON;
|
||||
|
||||
namespace WPCordovaClassLib.Cordova.Commands
|
||||
{
|
||||
public class ExitApp : BaseCommand
|
||||
{
|
||||
public void exitApp(string options)
|
||||
{
|
||||
Application.Current.Terminate();
|
||||
}
|
||||
}
|
||||
}
|
||||
10
plugins/cordova.custom.plugins.exitapp/www/ExitApp.js
Normal file
10
plugins/cordova.custom.plugins.exitapp/www/ExitApp.js
Normal file
@@ -0,0 +1,10 @@
|
||||
var exec = require('cordova/exec');
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Exits the PhoneGap application with no questions asked.
|
||||
*/
|
||||
exitApp: function() {
|
||||
exec(null, null, 'ExitApp', 'exitApp', []);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user