Which code? I've been through may iterations of code trying to get
this going. It's actually a pretty simple thing that's not working.
What i ended up with, which at least gets back to the code deviceready
would have called but is far from ideal, is:
<script type="text/javascript" charset="utf-8">
// PhoneGap is loaded and it is now safe to make calls PhoneGap
methods
//
var onDeviceReadyCallback = function() {
//alert("onDeviceReady called...");
// Now safe to use the PhoneGap API
listDirectory();
}
function onLoad() {
//alert("onLoad called...");
var state = document.readyState;
if (state == 'loaded' || state == 'complete') {
onDeviceReadyCallback();
} else {
if (navigator.userAgent.indexOf('Browzr') >
-1) {
setTimeout(run, 250);
} else {
document.addEventListener('deviceready',onDeviceReadyCallback,false);
}
}
}
</script>
(this is of course in the head section)
The deviceready event is not firing in Android or iOS emulators and
also not on a physical Android device (I haven't been able to test a
physical iOS device yet).
However, I've recently worked around it not firing (with the code
above) however I now get an error on a physical Android device (via
logcat):
Uncaught ReferenceError: DirectoryEntry is not defined at
file:///android_asset/www/index.html:97
This is starting to make me believe that the phonegap.js file is not
actually being loaded at all (which would explain the event not
getting fired).
This concerns me because the jquery-mobile files are getting loaded
just fine.
I'm about to resort to the Blackberry method of testing for a ready
device to see if I can generate any errors from phonegap (i.e. it's
not loaded and undefined).