问题描述
我建立我的申请通过的的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;
有关参考:的
这篇关于停止对出口的后退按钮的Andr oid PhoneGap的 - 建立的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!