0

i am new in android platform. I have set my android application to force portrait mode. Now , i have an activity group in my application. When i am in a child view of the activity group , then if i rotate my device the screen remains in portrait mode but the view changes from child view to parent view of the activity group. I don't know why this is happening. So please help me on the issue. Thanks in advance .... !!!

Junaid
  • 1,179
  • 2
  • 18
  • 35
  • Are you by any chance using the ViewFlipper? – Manuel Jun 22 '11 at 09:57
  • Nope i haven't , But i got my solution from here ( http://stackoverflow.com/questions/456211/activity-restart-on-rotation-android ) , I just had to add ' android:configChanges="keyboardHidden|orientation" ' to my manifest file and that worked .... anyways , Thanks ... :) @ dragon112 – Junaid Jun 22 '11 at 10:25
  • Could you add your solution as an answer an mark that as accepted answer? This could help other users with the same problem. – nhaarman Jun 22 '11 at 12:11

2 Answers2

1

You have to add android:configChanges="keyboardHidden|orientation" to every Activity node within a ActivityGroup in your application's manifest file when your application is on force portrait mode. Thus the view will not change.

Hussain
  • 5,552
  • 4
  • 40
  • 50
Junaid
  • 1,179
  • 2
  • 18
  • 35
1

I guess you missed something... You have to add 2 things to your activity in your manifest file.

android:screenOrientation="portrait" This one will keep the activity in the portrait mode itself, and wont change the orientation. But whenever you change the orientation of you device, The activity will try to restart. That is why your app came back to the parent activity. To avoid that we use the below config.

android:configChanges="keyboardHidden|orientation" When a configuration change occurs at runtime, the activity is shut down and restarted by default, but declaring a configuration with this attribute will prevent the activity from being restarted. Instead, the activity remains running and its onConfigurationChanged() method is called.

http://developer.android.com/guide/topics/manifest/activity-element.html#config

trio
  • 646
  • 2
  • 6
  • 16
  • Previously , I added ' android:screenOrientation="portrait" ' in manifest file's activties but just adding that was not working for me , Later when i added 'android:configChanges="keyboardHidden|orientation" ' with that that worked for me ...... :) – Junaid Jul 08 '11 at 05:07