7

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>
CoDe
  • 11,056
  • 14
  • 90
  • 197
manojmore
  • 410
  • 2
  • 8
  • 20

6 Answers6

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

Avadhani Y
  • 7,566
  • 19
  • 63
  • 90
  • thanks Avadhani Y for your prompt reply, i made the changes as you mentioned. In eclipse I am getting error "error: Error: String types not allowed (at 'configChanges' with value 'orientation|screenSize|keyboardHidden')." Do i have to add anything else? – manojmore Jul 03 '13 at 11:00
  • Inside the `manifest` tag in `AndroidManifest`, By the way, what are the values u have given for `android:minSdkVersion`, `android:targetSdkVersion` in `AndroidManifest.xml`?? use this: `` for `android:minSdkVersion` give the value whatever u want – Avadhani Y Jul 03 '13 at 11:06
  • 1
    Still No success. Here eclipse is not allowing me to enter value "orientation|screenSize|keyboardHidden" – manojmore Jul 03 '13 at 11:12
  • where are you adding. You have to add inside your `activity` tag. – Avadhani Y Jul 03 '13 at 11:15
  • 1
    yes i am adding it in activity tag only. as follows – manojmore Jul 03 '13 at 11:17
  • I have added the same above lines in my manifest and i am not getting any errors... Can u please show me ur complete manifest file by editing your question??? – Avadhani Y Jul 03 '13 at 11:20
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/32819/discussion-between-manojmore-and-avadhani-y) – manojmore Jul 03 '13 at 11:27
  • for me i had to add uiMode along with these config changes to make it work!! – Sjd Apr 04 '18 at 18:59
2

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>
Benazir
  • 240
  • 4
  • 6
0

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

<activity
            android:name="com.myapp.MainActivity"
            android:configChanges="orientation|keyboardHidden"/>
Spring Breaker
  • 8,233
  • 3
  • 36
  • 60
0

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
manojmore
  • 410
  • 2
  • 8
  • 20
0

Use your activity like this ...

 <activity
        android:name=".UserLoginActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:screenOrientation="unspecified" >
    </activity>
Sankar
  • 1,272
  • 2
  • 19
  • 31
0

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"
        >
Community
  • 1
  • 1
Kevin
  • 2,296
  • 21
  • 22