Reputation: 3054
my android application crashes and shows force close when i tilt the mobile phone. is there any suggestions that i can remove such problem? By the way i am developing a LBS application which uses the google maps (MapView).
I have a splash screen and then shown a ListActivity as below :
<activity android:name=".Splash" 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=".Home" android:label="@string/app_name" android:configChanges="orientation" android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="com.nepways.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
what is wrong with my declaration, the splash screen loads and list activity is also whown correctly but when i change the orientation the application is closed. Please help me.
Upvotes: 0
Views: 1899
Reputation: 2685
First of all as it is said the app is restarting (or as it is said in reference redrawing) each time when you change orientation. To block it in your manifest file in activity you have to put this line which describes the activity orientation:
<activity android:name=".Splash"
android:label="@string/app_name"
android:screenOrientation="portrait">...
And about this buttons, or keymaps. Telling the truth Ive got thise warnings sometimes but it doesn
t change anything in my app. So first change the orientation settings and then it should work correct.
If you want use other screen orientation remember to check here: http://developer.android.com/guide/topics/manifest/activity-element.html
Upvotes: 2
Reputation: 46543
When you change your orientation the activity is restarted
configChanges
, if you stil have the problem override onConfigurationChanged()
to fix what is generating this exception (like initialize something that may cause a nullpointer)Upvotes: 3
Reputation: 100448
If you want to avoid restarting your activity on orientation change, you can put this in the activity in the manifest file:
android:configChanges="orientation"
Otherwise, we will need to see more code, and a stacktrace.
Upvotes: 0