0

There is an activity which should not exist when a user leaves it. That's why it has finish() method in the onStop.

@Override
protected void onStop() {
    super.onStop();
    finish();
}

However, this makes it restart each time the screen orientation changes. At the moment I handle this via Manifest Activity tag android:configChanges="orientation" and overriding method onConfigurationChanged

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    setContentView(R.layout.someactivity);
    doAllInitializations();;
}

Is there a better way to handle such situations?

sandalone
  • 41,141
  • 63
  • 222
  • 338

1 Answers1

1

You can stop this orientation by adding android:configChanges="orientation|keyboardHidden" in your activity tag in the manifest file.

Vineet Shukla
  • 23,865
  • 10
  • 55
  • 63
  • THANKS A LOT! I thought that this attributes is a signal to app to throw an event when orientation changes which I handle in `onConfigurationChaged`. LOL – sandalone Jan 27 '12 at 10:49