Pumpkin
Pumpkin

Reputation: 2043

Android - Activity states newbie question

I am trying to make a quiz app in which the questions are all displayed on the same activity. Everytime the screen is rotated, on create method is recalled and the quiz returns back to its first question, losing all the data regarding the other questions.

How can I prevent this ?

Thanks.

*ps: I don't want my application to work only at portrait or landscape mode but at both.

Upvotes: 0

Views: 48

Answers (2)

nhaarman
nhaarman

Reputation: 100438

In your AndroidManifest, within your activity add:

android:configChanges="orientation"

So something like:

<activity android:name="MyActivity"
          android:configChanges="orientation" />

This will tell the app that you want to handle changes by orientation yourself. You can do nothing with it, or catch the corresponding method in your app.

Upvotes: 1

Nanne
Nanne

Reputation: 64419

You can add this to your activities entry:

android:configChanges="keyboardHidden|orientation"

Upvotes: 1

Related Questions