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?
You can stop this orientation by adding
android:configChanges="orientation|keyboardHidden"
in youractivity tag
in themanifest
file.