Forcing Portrait Orientation on Android PhoneGap
I’ve made some good progress on my Barcode Bots project: most notably I found out (after much flailing) how to force Portrait orientation in Android PhoneGap. A simple addition to the main class in my project’s _AndroidActivity.java did the trick (see below).
I’ve also added a new screen, the help screen, and was able to test the Barcode Scanner PhoneGap plugin on an actual device. Success! Download the current code here.
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
};
}



Sean Montgomery 10:09 pm on March 3, 2012 Permalink |
Looks good Nick. You button clicks weren’t all working for me in chrome and I couldn’t run your code on a device because I didn’t have the barcode lib project, so be sure to include that when you turn in your project next week. FYI, you can also enforce portrait mode (among other options) in the Android Manifest, but your way works fine too. 10/10 + 5/5 extra credit