手机差距 - navigator.app.exitApp()无法在Windows手机上运行

时间:2014-04-03 09:55:44

标签: cordova windows-phone-8

我是phonegap的新手。我正在开发一个Windows应用程序。在该应用中,我正在尝试使用navigator.app.exitApp()。但它不起作用,我一直在尝试在我的项目中添加自定义插件。所以我已经下载了cordova-plugin-exitapp-master.zip

在具有以下文件的zip文件中

cordova-plugin-exitapp-master/plugin.xml
cordova-plugin-exitapp-master/www/ExitApp.js
cordova-plugin-exitapp-master/src/wp/ExitApp.cs

科尔多瓦-插件-ExitApp命令主/ plugin.xml的

<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
       id="se.sanitarium.cordova.exitapp"
       version="1.0.0">

<name>ExitApp</name>
<description>Implements navigator.app.exitApp on WP8</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>
</plugin>

科尔多瓦-插件-ExitApp命令主机/网络/ ExitApp.js

var exec = require('cordova/exec');

module.exports = {
/**
 * Exits the PhoneGap application with no questions asked.
 */
 exitApp: function() {
 exec(null, null, 'ExitApp', 'exitApp', []);
}
};

科尔多瓦-插件-ExitApp命令主/ SRC / WP / ExitApp.cs

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();
    }
  }
}

所以,请你告诉我任何身体。在我的项目中,我必须在哪个地方添加插件?

1 个答案:

答案 0 :(得分:1)

//在您要退出应用程序的函数内部,只写下以下语句,不需要任何插件或其他任何东西来退出应用程序

    function abc[you have to write the name instead of abc]{  
   IsolatedStorageSettings.ApplicationSettings.Save();//you may skip this line   
      Application.Current.Terminate();                          
}