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>

 


Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit