0

I have a CharSequence which displays a sequence of text after each imageview click however the CharSequence seems to restart if the orientation is changed mid sequence.

Does anyone know how this can be resolved?

OhNoItsAnOverflow
  • 237
  • 2
  • 5
  • 13

3 Answers3

0

On an orientation change the activity is restarted, and the inCreate() is called again. You have to take that in consideration.

hakanostrom
  • 1,081
  • 8
  • 15
0

A small example of how to store and retrieve a value:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        isStarted = savedInstanceState.getBoolean("isStarted");
    }
}

@Override
protected void onResume() {
    isStarted = true;
    super.onResume();
}

@Override
protected void onSaveInstanceState(Bundle outState) {
    outState.putBoolean("isStarted", isStarted);
    super.onSaveInstanceState(outState);
}

For more information and methods: Saving Android Activity state using Save Instance State

Community
  • 1
  • 1
cYrixmorten
  • 7,110
  • 3
  • 25
  • 33
-1

using android:configChanges="orientation|keyboardHidden|screenSize"> resolved the issue

OhNoItsAnOverflow
  • 237
  • 2
  • 5
  • 13
  • 1
    Please no: http://stackoverflow.com/questions/7818717/why-not-use-always-androidconfigchanges-keyboardhiddenorientation – cYrixmorten Sep 26 '13 at 22:23