Hi,
is there a way to make application to completely ignore screen orientation change?
Thanks.
Hi,
is there a way to make application to completely ignore screen orientation change?
Thanks.
It is possible, quite easily, to override default behavior and forbid screen orientation change when keyboard is open/closed.
Modifying manifest
Open manifest, switch to Application tab and select desired Activity you wish to override orientation change behavior.
Modifying Activity implementation
Now you need to override single function within desired Activity.
Just add below function to your Activity's class.
@Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); }
This is default implementation if using Source->Override/Implement Methods menu option.
That's it! Now your orientation will be kept always.
Remeber that this setting is per Activity - so you need to repeat this step for each Activity you wish to forbid orientation change!
(based on SDK 1.1)
You can make the same change in code with the following line (called in an activity):
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Once you make this call, your application will stay in landscape (or portrait), you can use the same call (with a different ActivityInfo enum) to make it sensitive to the orientation shifting again.
There's a full DevX article on the topic here: http://www.devx.com/wireless/Article/40792
(WARNING: since I've posted this link devx has put up a registration wall)
You can define your activity in AndroidManifest.xml like this:
<activity
android:name=".MyActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|keyboard"/>
In this case you should set the property for each activity. I didn't find inline solution for all application.
Just one note that apparently in Android 1.5 there is a bug. If you use a custom screen size (e.g. 800x480, like on the Apad) and force it to landscape (either via XML or from the code) then it will be in fact in portrait.