PhoneGap application crashing when rotating

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>

 


11 thoughts on “PhoneGap application crashing when rotating

  1. Drop me an email margus dot pala at gmail.com, maybe i can help you to review the code and fix it.

  2. check that both activities have the:
    android:configChanges=”orientation|keyboardHidden”

  3. also try to add screenSize
    android:configChanges=”orientation|screenSize|keyboardHidden”

  4. also try to add screenSize
    android:configChanges=”orientation|screenSize|keyboardHidden”

    ^^ This helps, thanks!

  5. great!

    android:configChanges=”orientation|screenSize|keyboardHidden” works for me 🙂 thx

  6. this didnt work for me, BUT! i moved android:configChanges=”orientation|keyboardHidden|keyboard|screenSize|locale”

    to the 1st line after <activity

    and it worked!

Leave a Reply

Your email address will not be published.


*