Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application crashed when orientation change

Actually my problem is the same as the question posted in : the same problem

But there is no answer yet..

Here is the problem I got :
I've just built an application using sencha touch & phone gap. It runs well on my galaxy tab but when I rotate it to portrait or landscape, it is going crash.
I have added :

android:configChanges="orientation|keyboardHidden"

on my manifest file but it is still going crash when I rotate it.

I don't know how could this happen.
Could someone help me?


Note :
I'm using
- Galaxy tab
- Sencha-touch 1.1
- Phone gap 1.2

like image 418
Yagi Avatar asked Jan 04 '12 09:01

Yagi


People also ask

How do I stop Android from restarting activity when changing orientations?

Prevent Activity to recreated Another most common solution to dealing with orientation changes by setting the android:configChanges flag on your Activity in AndroidManifest. xml. Using this attribute your Activities won't be recreated and all your views and data will still be there after orientation change.

What happens when orientation changes Android?

When you rotate your device and the screen changes orientation, Android usually destroys your application's existing Activities and Fragments and recreates them . Android does this so that your application can reload resources based on the new configuration.


2 Answers

You should have

android:configChanges="keyboardHidden|orientation|screenLayout"

instead of

android:configChanges="orientation|keyboardHidden"

to your activity in the manifest

like image 56
Maurizio Pozzobon Avatar answered Sep 21 '22 22:09

Maurizio Pozzobon


Might be a bit late... but since I've recently been trying this, I found that specifying

android:configChanges="orientation|screenSize|keyboardHidden"

works where as

android:configChanges="keyboardHidden|orientation|screenLayout"

does NOT.

I'm using cordova 2.0.0.

like image 26
user1137874 Avatar answered Sep 18 '22 22:09

user1137874