How to prevent activity restart upon orientation changes

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to prevent activity restart upon orientation changes

Postby tensaix2j » Wed Apr 08, 2009 3:46 am

I have already overiden the method

onConfigurationChanged

but still when users open or close the keyboard, or change the orientation,
the activity will be restarted...

why and how to overcome this??
tensaix2j
Freshman
Freshman
 
Posts: 5
Joined: Tue Jan 06, 2009 7:35 am

Top

Postby Sowmya » Wed Apr 08, 2009 6:56 am

Hi,
You have to add
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. android:configChanges="keyboardHidden|orientation"
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

to your activity in AndroidManifest file


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.   <application android:icon="@drawable/icon" android:label="@string/app_name">
  2.  
  3.         <activity android:name=".TestActivity"
  4.  
  5.                  android:label="@string/app_name"
  6.  
  7.                   android:configChanges="keyboardHidden|orientation">
  8.  
  9.             <intent-filter>
  10.  
  11.                 <action android:name="android.intent.action.MAIN" />
  12.  
  13.                 <category android:name="android.intent.category.LAUNCHER" />
  14.  
  15.             </intent-filter>
  16.  
  17.         </activity>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4



I dont know if it is best practice.
Sowmya
Experienced Developer
Experienced Developer
 
Posts: 51
Joined: Fri Mar 06, 2009 7:49 am

Postby tensaix2j » Thu Apr 09, 2009 2:34 am

it works like a charm. Thank you
tensaix2j
Freshman
Freshman
 
Posts: 5
Joined: Tue Jan 06, 2009 7:35 am

Postby sandis84 » Thu Sep 10, 2009 4:23 pm

This is madness, how come I never heard of it before? Thanks very much for informing me. How come it is standard to wipe all data when changing orientation? What purpose does it have?
sandis84
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Fri Aug 07, 2009 3:54 pm

Postby umair » Thu Oct 01, 2009 5:05 am

sandis84 wrote:This is madness, how come I never heard of it before? Thanks very much for informing me. How come it is standard to wipe all data when changing orientation? What purpose does it have?

You are sandis, there are some things which are un-understandable.

Thanks Sowmya for sharing :)
Muhammad Umair
User avatar
umair
Developer
Developer
 
Posts: 28
Joined: Thu Feb 26, 2009 1:00 pm
Location: Lahore, Pakistan

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 9 guests