简体   繁体   English

本机功能无法与PhoneGap配合使用-Co​​rdova

[英]Native functionality no working with PhoneGap - Cordova

I have implemented several functions for the android native buttons as specified in the PhoneGap referrence: 我已经为PhoneGap参考中指定的android native按钮实现了几个功能:

js: js:

var _previous;
function bindCordovaNativeHandlers(){
    document.addEventListener("deviceready", onDeviceReady, false);
}

function onDeviceReady(){
    document.addEventListener("menubutton", onMenuKeyDown, false);
    document.addEventListener("backbutton", onBackKeyDown, false);
}

function onMenuKeyDown(){
    //open function bar
    $('.action').click();
}

function onBackKeyDown() {
    //quit funciton
    var interval = 2000,
        current = Date.now();

    _previous = _previous || 0;

    console.log(current - _previous);
    if (current - _previous <= interval) {
        navigator.app.exitApp();

    }
    _previous = current;
}

html: 的HTML:

in order to not cause any suspicision from my users, I would like to require the minimal amount of permissions (cordova plugins are translated into android permissions). 为了不引起我的用户的怀疑,我想要求最少的权限(cordova插件被翻译成android权限)。

Are there any cordova plugins that are required for that functionality? 该功能是否需要任何cordova插件?

Plugins that I've removed on the last build: 我在上一个版本中删除的插件:

 <gap:plugin name="org.apache.cordova.battery-status" />
    <gap:plugin name="org.apache.cordova.camera" />
    <gap:plugin name="org.apache.cordova.media-capture" />
    <gap:plugin name="org.apache.cordova.console" />
    <gap:plugin name="org.apache.cordova.contacts" />
    <gap:plugin name="org.apache.cordova.device" />
    <gap:plugin name="org.apache.cordova.device-motion" />
    <gap:plugin name="org.apache.cordova.device-orientation" />
    <gap:plugin name="org.apache.cordova.dialogs" />
    <gap:plugin name="org.apache.cordova.file" />
    <gap:plugin name="org.apache.cordova.file-transfer" />
    <gap:plugin name="org.apache.cordova.geolocation" />
    <gap:plugin name="org.apache.cordova.globalization" />
    <gap:plugin name="org.apache.cordova.inappbrowser" />
    <gap:plugin name="org.apache.cordova.media" />
    <gap:plugin name="org.apache.cordova.network-information" />
    <gap:plugin name="org.apache.cordova.splashscreen" />
    <gap:plugin name="org.apache.cordova.vibration" />

Well, the answer is that it didn't work since, as noted in the PhoneGap documentation, you should add a reference for cordova.js, which is injected into the root of your project during the build process depending on the operating system of the device the build is for. 好吧,答案是它没有用,因为正如PhoneGap文档中所述,您应该添加cordova.js的引用,该引用将在构建过程中注入到项目的根目录中,具体取决于操作系统的操作系统。该构建适用的设备。

eg: 例如:

<script src="cordova.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM