2011-12-29 64 views
1

我有一個帶有phonegap 1.3和jquerymobile 1.0的web應用程序,可以在所有的android版本上運行,但是4.0 事實上,如果我改變方向,應用程序強制關閉,沒有錯誤,我可以理解)logcat錯誤。 如果我開我的肖像的應用程序的工作,如果我打開園林景觀工程,但如果我嘗試切換關閉帶電話的Android 4.x方向

這裏是我的代碼:

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"); 
    } 
} 
當然

我已經

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

在清單中!

感謝您的幫助

回答

6

嘗試添加此:

android:configChanges="orientation|screenSize|keyboardHidden" 

爲你的配置變化的參數,看看是否能解決您的問題。

+0

作品中,我不得不把SDK指向3.2,我是2.2 – 2012-01-05 10:06:45

+2

哦,你應該始終建立與最新的SDK應用程序,然後讓Android處理向後兼容性。您可以指定一個min sdk版本,您的應用程序可以在清單文件中運行。對於此值,我不會低於7(Android 2.1)。 – 2012-01-11 15:27:15

1

我有相同的旋轉問題,並拿到應用程序的最新版本的SDK 4.03,和上述配置更改。我的清單如下所示:

<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>