1

我的应用程序有以下清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.netserv.Pungry"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:maxSdkVersion="17"
        android:minSdkVersion="5" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />

    <!-- <meta-data -->
    <!-- android:name="ADMOB_ALLOW_LOCATION_FOR_ADS" -->
    <!-- android:value="true" /> -->

    <meta-data
        android:name="ADMOB_PUBLISHER_ID"
        android:value="a150cb2e31846cf" />

    <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@drawable/bghomescreen"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.netserv.Pungry.Home"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".LocationbyCities" >
        </activity>
        <activity android:name=".General" >
        </activity>
        <activity android:name=".RestaurantsList" >
        </activity>
        <activity android:name=".Quickbite" >
        </activity>
        <activity android:name=".AdvanceSearch" >
        </activity>
        <activity android:name=".SelectMenu" >
        </activity>
        <activity android:name=".RestaurantDetails" >
        </activity>
        <activity
            android:name="com.google.ads.AdActivity"
            android:configChanges="orientation|uiMode|keyboard|keyboardHidden|screenSize|smallestScreenSize|screenLayout" />

        <receiver android:name=".UpdateReceiver" >
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
        </receiver>
    </application>

</manifest>

当我将应用程序加载到设备时,它在纵向模式下工作正常。但是,当我从纵向模式更改为横向模式时,它会转换为一些不正确的活动,有时应用程序本身会关闭。

我已经在纵向布局中定义了布局,在横向模式下定义了布局。

我不想将方向固定为纵向模式。

4

2 回答 2

0

尝试覆盖这两种方法。它解决了我的问题。

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        webView.saveState(outState);            
        super.onSaveInstanceState(outState);
    }

    @Override
    protected void onRestoreInstanceState(Bundle inState) {
        webView.restoreState(inState); 
        super.onRestoreInstanceState(inState);
    }

希望有帮助。

于 2013-04-15T12:19:06.237 回答
0

只需在所有活动中使用 configChange 属性

<activity
    android:name="com.netserv.Pungry.Home"
    android:label="@string/app_name"
    android:configChange="orientation|screenSize" > <!-- like this use this attribute in all activities -->
于 2013-04-15T12:21:06.000 回答