Android 4.x orientation with phonegap

对着背影说爱祢 提交于 2019-12-19 04:39:20

问题


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


回答1:


Try adding this:

android:configChanges="orientation|screenSize|keyboardHidden" 

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




回答2:


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>


来源:https://stackoverflow.com/questions/8667489/android-4-x-orientation-with-phonegap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!