简体   繁体   中英

Android app closes when the orientation is changed

I want my app to run in the portrait view so I made the following changes in the android manifest file.

android:screenOrientation="portrait"

It stays in the portrait view for a second and then it closes.. I had assumed this is the only change i had to make..but i also added this but it isnt working

 android:configChanges="orientation"

Am i missing something?

     <activity android:name=".Menu" android:label="COMEDY TRIVIA"
        android:screenOrientation="portrait" android:configChanges="orientation"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
        <intent-filter>
            <action android:name="nik.trivia.MENU" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

Try this adding android:configChanges to your AndroidManifest file in the activity tag

<activity android:name=".Fourth" android:label="Fourth" android:configChanges="orientation|keyboardHidden"></activity>

Hope this works for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM