1

I've a web app with phonegap 1.3 and jquerymobile 1.0 that works well on all android version but 4.0 In fact if I change the orientation the app force close with no errors and no (as I can understand) logcat errors. If I open my app in portrait works, If I open in landscape works but if I try to switch closes

Here's my code:

import android.os.Bundle;
import com.phonegap.DroidGap;
public class MYActivity extends DroidGap {
         @Override 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }   
}

of course I've

        android:configChanges="keyboardHidden|orientation" 
        android:screenOrientation="sensor"

in manifest !

thanks for help

Leonardo Gandini
  • 238
  • 1
  • 15

2 Answers2

6

Try adding this:

android:configChanges="orientation|screenSize|keyboardHidden" 

as your config change parameter to see if it fixes your issue.

Simon MacDonald
  • 23,253
  • 5
  • 58
  • 74
  • 2
    Oh, you should always build your application with the latest SDK and let Android handle the backwards compatibility. You can specify a min sdk version that your app can run on in the manifest file. I would not go lower than 7 (Android 2.1) for this value. – Simon MacDonald Jan 11 '12 at 15:27
1

I had the same rotation problem and took the app to the latest version of the sdk 4.03, and the above mentioned configuration changes. My manifest looks like the following:

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="13" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".Ordering"
        android:configChanges="orientation|screenSize|keyboardHidden"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <!-- ZXing activities -->
    <activity
        android:name="com.google.zxing.client.android.CaptureActivity"
        android:configChanges="orientation|screenSize|keyboardHidden"
        android:screenOrientation="landscape"
        android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
        android:windowSoftInputMode="stateAlwaysHidden" >
        <intent-filter>
            <action android:name="com.phonegap.plugins.barcodescanner.SCAN" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.google.zxing.client.android.encode.EncodeActivity"
        android:configChanges="orientation|keyboardHidden|screenSize"
        android:label="@string/share_name" >
        <intent-filter>
            <action android:name="com.phonegap.plugins.barcodescanner.ENCODE" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
</application>
Steve Ruch
  • 11
  • 1