I have seen some apps that crash when rotating from landscape to portrait or vice versa. Beginners might not have such problem as coping original PhoneGap examples with all bloating overhead works. On hte other hand some applications that I created as new project in eclipse and wrote PhoneGap app from scratch had the rotation crash issue.
It was tracked down to one line in AndroidManifest.xml. Make sure that you have
android:configChanges="orientation|keyboardHidden"
in your main activity where you call
super.loadUrl("file:///android_asset/www/index.html");
and PhoneGap jQuery Mobile application will not crash anymore when phone is rotating.
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.marguspala.perftest.phonegap" android:versionCode="5" android:versionName="1.1" android:windowSoftInputMode="adjustPan" > <uses-permission android:name="android.permission.INTERNET" /> <application android:debuggable="true" android:label="@string/app_name" > <activity android:configChanges="orientation|keyboardHidden" android:label="@string/app_name" android:name="PerfTestPhonegapActivity" > <intent-filter > <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:configChanges="orientation|keyboardHidden" android:label="@string/app_name" android:name="com.phonegap.DroidGap" > <intent-filter > </intent-filter> </activity> </application> </manifest>






#1 by Ken Deeds on February 10, 2012 - 18:55
Quote
Mine has these lines and crashes like no tomorrow on rotation.
#2 by smartman on February 10, 2012 - 19:02
Quote
Drop me an email margus dot pala at gmail.com, maybe i can help you to review the code and fix it.
#3 by Stephen Brown on April 26, 2012 - 13:15
Quote
Mine drops too and the code is the same
#4 by EniGMistA on May 3, 2012 - 12:00
Quote
Thanks
#5 by name required on May 14, 2012 - 11:53
Quote
check that both activities have the:
android:configChanges=”orientation|keyboardHidden”
#6 by Steve on July 17, 2012 - 04:42
Quote
ditto
#7 by name required on July 24, 2012 - 18:29
Quote
also try to add screenSize
android:configChanges=”orientation|screenSize|keyboardHidden”
#8 by BDS on July 31, 2012 - 18:36
Quote
I’m having the same problem, using SDK8, cordova 1.8 here’s my manifest:
#9 by FTW on September 11, 2012 - 10:42
Quote
also try to add screenSize
android:configChanges=”orientation|screenSize|keyboardHidden”
^^ This helps, thanks!
#10 by Schnasi on October 5, 2012 - 09:11
Quote
great!
android:configChanges=”orientation|screenSize|keyboardHidden” works for me
thx
#11 by Jesus on October 27, 2012 - 08:35
Quote
this didnt work for me, BUT! i moved android:configChanges=”orientation|keyboardHidden|keyboard|screenSize|locale”
to the 1st line after <activity
and it worked!