Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Android加载URL时未调用PhoneGap ondeviceready_Android_Cordova - Fatal编程技术网

使用Android加载URL时未调用PhoneGap ondeviceready

使用Android加载URL时未调用PhoneGap ondeviceready,android,cordova,Android,Cordova,index.html加载到MainAction中 index.html中有一个链接将转到game.html。因为我需要index.html和game.html来使用横向屏幕,所以我不能在index.html中使用类似的东西。否则,只有index.html将使用landscapre,而game.html将使用由设备方向决定的屏幕,这是不可能的。所以我用Java创建了一个类来控制网页的加载: public class JsHelper { private MainActivity activ

index.html
加载到MainAction中

index.html
中有一个链接将转到
game.html
。因为我需要
index.html
game.html
来使用横向屏幕,所以我不能在
index.html
中使用类似
的东西。否则,只有
index.html
将使用landscapre,而
game.html
将使用由设备方向决定的屏幕,这是不可能的。所以我用Java创建了一个类来控制网页的加载:

public class JsHelper {
    private MainActivity activity;

    public JsHelper(MainActivity act) {
        activity = act;
    }

    public void goToHtml(String url) {
        activity.loadUrl("file:///android_asset/www/" + url);
    }
}
index.html
中,我调用它转到
game.html

window.JsHelper.goToHtml("game.html");
这是我使用横向屏幕制作
game.html
的唯一方法

但问题是

如果
document.addEventListener('devicerady',init,true)
位于
index.html
中,
init()
将被调用一次

但是如果它在
game.html
中,则永远不会调用
init()
,即使没有
文档
index.html

game.html:

$(document).ready(function() {
    document.addEventListener('deviceready', init, false);
}

function init() {
    alert("init");
}
API中的东西将不起作用<代码>导航器。加速计将为空

我想使用
navigator.accelerator
并确保
game.html
使用横向。
请帮帮我

我看不出你为什么不在game.html网站上发起“DeviceRady”活动。您只需添加带有脚本标记的cordova.js,它就会启动

function ondeviceready(){

     //Call Cordova Functions here
}

对不起,我帮不了你。Cordova不启动它的唯一原因是jQuery的document.ready没有启动,或者Cordova.js没有包含在HTML文件中。你能在Firefox或Chrome中打开Game.html并检查cordova.js和jQuery.js是否正确加载吗?