Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

deviceready not firing when running my Phonegap app on IceCreamSandwich

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();
}
like image 464
PBN Avatar asked Dec 14 '25 16:12

PBN


1 Answers

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();
    } 
}
like image 86
tehnorm Avatar answered Dec 17 '25 04:12

tehnorm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!