停止对出口的后退按钮的Andr​​ oid PhoneGap的 - 建立 [英] Stop Exit on Back Button Android in PhoneGap - Build

查看:102
本文介绍了停止对出口的后退按钮的Andr​​ oid PhoneGap的 - 建立的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立我的申请通过的的PhoneGap构建在线。 我想改变后退按钮的默认行为

I'm building my application through PhoneGap Build online. I want to change the default behavior of Back Button

$(document).ready(function(e) {
    document.addEventListener("backbutton", onBackKeyDown, false);
});

function onBackKeyDown(){
    alert('back');
    return false;
}

它不工作我已经搜索了解决方案。但是,他们都显示出改变的的Java codeS里的PhoneGap库,这是不是在我的情况。我提交我的应用程序中的的.zip 的带格式的的config.xml 的里面。

Its not working I've searched for solution. But, they all showing to change the java codes in PhoneGap library, which is not in my case. I'm submitting my application in a .zip format with config.xml inside.

是否有可能用的的config.xml 的?

推荐答案

首先,我做错了正如由@Mejo,致谢。这里是解决问题的办法。

First of all I did wrong as pointed by @Mejo, Thanks. Here is the solution to the problem.

第1步:包含脚本的HTML并不实际中应用程序zip需要它,因为包含的自动的PhoneGap构建

Step 1: Include Script to HTML don't need it physically within application zip, as included automatically by PhoneGap Build

<脚本SRC =cordova.js>< / SCRIPT> <脚本SRC =phonegap.js >< / SCRIPT> 其中任何一个将正常工作

<script src="cordova.js"></script> or <script src="phonegap.js"></script> any of them will work fine.

第二步:此加入脚本获取设备准备好电话:

Step 2: Add this to script to get device ready call:

document.addEventListener("deviceready", onDeviceReady, false);

第三步:添加事件监听器的为后退按钮并添加code到呼叫:

Step 3: Add event listener to back button and add your code to that call:

function onDeviceReady(){
    document.addEventListener("backbutton", onBackKeyDown, false);
}
function onBackKeyDown(){
    alert('back');
    return false;
}

不过现在如果你不设置preference将无法正常工作 minSDK 以应用程序通过的的config.xml

Still now it will not work if you don't set preference of minSDK to application by config.xml

第四步:本加入了preference区域的的config.xml

Step 4: Add this to preference region of config.xml

&LT; preference名=Android的的minSdkVersion值=5/&GT;

有关参考:的http://community.phonegap.com/nitobi/topics/how_to_handle_back_button_in_android

这篇关于停止对出口的后退按钮的Andr​​ oid PhoneGap的 - 建立的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆