manojmore
manojmore

Reputation: 410

android configChange:orientation and manifest does not work

I have used a Web view. which loads webpage. When i orientation is changed it reloads. I want to stop reloading. I did following change in manifest XML File. It works in android 2.2 but not in android 4.0. I am a beginner can any one provide solution.

My Manifest.xml is;

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="application.eag"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main"
            android:configChanges="orientation|screenSize|keyboardHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

Upvotes: 7

Views: 14643

Answers (6)

Benazir
Benazir

Reputation: 260

This one worked for me:

    <activity android:name=".YourActivity"
        android:configChanges="orientation|screenSize|keyboardHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Upvotes: 2

Kevin
Kevin

Reputation: 2426

I couldn't get any of these to work, but then I got it (not sure what was going on but thought I'd elaborate on other answers to save people time). I found the below to work for my app (1 line in your manifest INSIDE the tag, for the activity you want this behavior for. I also discovered it completely depends on your app on what you need here. For a complete list see http://developer.android.com/guide/topics/manifest/activity-element.html#config

And by 'doesn't work', I mean the onDestroy() method got called every time I rotated my device. See Why not use always android:configChanges="keyboardHidden|orientation"? for reasons you likely shouldn't use this.

Manifest.xml:

<activity
        android:name="com.example.MainActivity"
        android:label="@string/app_name"
        android:launchMode="singleTop"
        android:configChanges="orientation|screenSize"
        >

Upvotes: 0

Sankar
Sankar

Reputation: 1292

Use your activity like this ...

 <activity
        android:name=".UserLoginActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:screenOrientation="unspecified" >
    </activity>

Upvotes: 0

manojmore
manojmore

Reputation: 410

Made changes as answered by Avadhani Y 1) Added following in manifest

<activity
android:name=".ActivityName"
android:configChanges="orientation|screenSize|keyboardHidden"/>

2) changed manifest as

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

3) in project.properties set the following value

# Project target.
target=android-13

Upvotes: 0

Spring Breaker
Spring Breaker

Reputation: 8251

I am using like the following and it works for me.

<activity
            android:name="com.myapp.MainActivity"
            android:configChanges="orientation|keyboardHidden"/>

Upvotes: 0

Avadhani Y
Avadhani Y

Reputation: 7646

<activity
    android:name=".ActivityName"
    android:configChanges="orientation|screenSize|keyboardHidden"/>

Use screenSize for newly version. orientation might not be supported in some version, need to use screenSize for configChanges

Upvotes: 25

Related Questions