Starting in PhoneGap 0.9.5 there’s an undocumented iOS only feature that allows you to handle whether the device should rotate to a particular orientation. It exposes the iOS Objective-C method shouldAutorotateToInterfaceOrientation with a JavaScript function shouldRotateToOrientation.
function shouldRotateToOrientation (rotation) {
switch (rotation) {
//Portrait or PortraitUpsideDown
case 0:
case 180:
return true;
//LandscapeRight or LandscapeLeft
case 90:
case -90:
return false;
}
}
This needs to be in the global scope of your JavaScript and will get called before any rotations occur, so keep it lean to avoid locking up the UI. Returning true allows the device to rotate, returning false prevents it.
Works great in your HTML5 iOS, iPhone and iPad apps, sadly currently there’s no Android or other platform integration. Hopefully we’ll see a cross-platform method soon!
So Android 2.3 is being rolled out the next few days, and will be available on the Nexus One and the new Nexus S initially. It’s got some much needed UI tidying up (till HTC get to it), but here’s what else is cool in it:
Android 2.3 iPhone like Copy & Paste
iPhone-esque Select, Copy and Paste
You can now select a group of text easily without using the trackball.
Tapping on a single word also selects it.
Front Facing Camera support on Android 2.3
Front Facing Camera
Sure lots of third party apps will support this, but I wonder if we’ll see a Google FaceTime competitor? They’ve got the infrastructure in place, so I’m sure it’s coming..
Near Field Communications on Android 2.3
NFC– Near Field Communications
Think of this as QR codes without the aggravation of having to fire up the camera and waiting for focus. Expect these to be popping up everywhere over the next 12-18 months.
Other notables
‘Overscroll’ – kinda like bounce scroll on iPhone, an effect to hint when you get to the beginning or end of a scrollable area
Support for ‘Extra Large’ Screens – hints at tablet support finally coming
Download Manager – universal across all apps, something iOS currently lacks
SIP Support – make phone calls over the web
Extended sensor support- gyroscope, rotation vector, linear acceleration, gravity, and barometer hardware now supported
VP8 and WebM- video codecs Google are pushing for HTML5 video