在IceCreamSandwich运行我的PhoneGap应用程序时deviceready不点火 [英] deviceready not firing when running my Phonegap app on IceCreamSandwich

查看:103
本文介绍了在IceCreamSandwich运行我的PhoneGap应用程序时deviceready不点火的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用的PhoneGap和jQuery Mobile的移动应用。
该应用程序就像在iOS上一个魅力和Android 2.3,但不幸的是没有冰淇淋三明治(在模拟器并在Nexus S的,以及测试)。
有谁经历了这个问题?

我使用的PhoneGap-1.3.0

加载code是以下内容:

 函数onBodyLoad(){
    如果($ .browser.webkit){
        phonega pready = TRUE;
    }
    document.addEventListener(deviceready,onDeviceReady,FALSE);
}功能onDeviceReady(){
    //电话峡是准备好了!
    phonega pready = TRUE;
    onAllReady();
}


解决方案

也看到同样的事情发生与PhoneGap的-1.3.0 + JQM在Android模拟器。它似乎并不像deviceready被解雇。如果我称之为 onDeviceReady()直接一切都很好。目前正在使用这个技巧:

 函数onBodyLoad(){    如果(navigator.userAgent.match(/ Android版/ I)){
             onDeviceReady();
    }否则如果(typeof运算navigator.device ==未定义){
            document.addEventListener(deviceready,onDeviceReady,FALSE);
    }其他{
             onDeviceReady();
    }
}

I'm developing a mobile app using phonegap and jQuery Mobile. The app works like a charm on iOS and android 2.3 but it unfortunately not on ice cream sandwich (tested on the emulator and on a nexus s as well). Does anyone has experienced this issue?

I'm using phonegap-1.3.0

the loading code is the following:

function onBodyLoad() {
    if ($.browser.webkit) {
        phonegapReady = true;
    }
    document.addEventListener("deviceready", onDeviceReady, false);
}

function onDeviceReady() {
    //Phone Gap is ready!
    phonegapReady = true;
    onAllReady();
}

解决方案

Also seeing the same thing happen with phonegap-1.3.0 + JQM in the android emulator. It doesn't seem like the deviceready is firing. If I call onDeviceReady() directly all is well. Currently using this hack:

function onBodyLoad() { 

    if( navigator.userAgent.match(/Android/i) ) {
             onDeviceReady();
    } else if (typeof navigator.device == "undefined"){
            document.addEventListener("deviceready", onDeviceReady, false);
    } else {
             onDeviceReady();
    } 
}

这篇关于在IceCreamSandwich运行我的PhoneGap应用程序时deviceready不点火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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