the little things I learned today about Android/Cordova/PhoneGap

For work, I had to help test a cordova iOS app and port it for Android. For some reason, the usual deviceready code wasn’t working:

if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/)) { 
     // is on PhoneGap
     $(function() {
        document.addEventListener("deviceready", deviceIsReady, false);
     });
} else {
     // not on PhoneGap
}

Instead, this worked:

if ( window.device ) {
      document.addEventListener("deviceready", deviceIsReady, false);
}
// not on PhoneGap
else {
     // what else
}

The other thing: I have no idea how to take screenshots on Android devices. To be honest, I still have no idea how to do it on my Nexus 7. Even less idea on how to do it on Android 3.0. Google search lead me to this and I still don’t understand why it has to be so hard (or confusing).



Comments

Leave a Reply

Your email address will not be published. Required fields are marked *