【问题标题】:Android 4.x orientation with phonegap带有 phonegap 的 Android 4.x 方向
【发布时间】:2011-12-29 11:49:05
【问题描述】:

我有一个带有 phonegap 1.3 和 jquerymobile 1.0 的网络应用程序,可以在除 4.0 之外的所有 android 版本上运行良好 事实上,如果我改变方向,应用程序强制关闭,没有错误,也没有(据我所知)logcat 错误。 如果我以纵向作品打开我的应用程序,如果我以横向作品打开但如果我尝试切换关闭

这是我的代码:

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"

在清单中!

感谢帮助

【问题讨论】:

    标签: android jquery-mobile cordova


    【解决方案1】:

    尝试添加这个:

    android:configChanges="orientation|screenSize|keyboardHidden" 
    

    作为您的配置更改参数,看看它是否解决了您的问题。

    【讨论】:

    • 哦,您应该始终使用最新的 SDK 构建您的应用程序,并让 Android 处理向后兼容性。您可以在清单文件中指定您的应用可以在其上运行的最小 sdk 版本。对于这个值,我不会低于 7(Android 2.1)。
    【解决方案2】:

    我也遇到了同样的轮换问题,把app带到了最新版本的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>
    

    【讨论】:

      猜你喜欢
      • 2013-04-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多