Home Forum
Welcome, Guest
Username Password: Remember me

Forcing portrait mode
(1 viewing) (1) Guest
Discussion related to creating Android software
  • Page:
  • 1

TOPIC: Forcing portrait mode

Forcing portrait mode 2 years, 7 months ago #230

You can stop an App from destroying and recreating itself on an orientation change by updating all the Activities in AndroidManifest.xml as follows:

 
<activity android:name=".SilverballSmashActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
 
<activity android:name=".AppSettings"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
/>
 
<activity android:name=".hiscore.HiscoresList"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden"
/>
 
And then in your Activity:
 
@Override
public void onConfigurationChanged(Configuration newCfg) {
//ignore orientation change
super.onConfigurationChanged(newCfg);
}
 
 
  • ticktock
  • OFFLINE
  • Professor
  • Posts: 79
  • Karma: 6
Last Edit: 2 years, 7 months ago by ticktock.
  • Page:
  • 1
Time to create page: 0.20 seconds
Copyright © 2012 Android Academy. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.
 
Glossary
We have 31 guests online