In my Android application I have a main activity “MyActivity” which overrides onConfigurationChanged() method. Within that method I check for a change in the orientation, if changed to landscape then I call another activity:
@Override
public void onConfigurationChanged(Configuration newConfig)
{
if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE)
{
super.onConfigurationChanged(newConfig);
startActivity(new Intent(this, BaseFullScreenActivity.class));
}
}
Then when I change my mobile to landscape orientation the other activity class “BaseFullScreenActivity” is called, which works fine. Within that called activity I again override the onConfigurationChanged() method to end this child activity again:
@Override
public void onConfigurationChanged(Configuration newConfig)
{
if(newConfig.orientation == Configuration.ORIENTATION_PORTRAIT)
{
super.onConfigurationChanged(newConfig);
finish();
}
}
However, at this second orientation change (back to portrait), which should end my child activity and show the main activity again, the app crashes and I receive the following error:
android.app.SuperNotCalledException:
Activity MyActivity did not call through to super.onConfigurationChanged()
I did override the onStop() method in both activities and call to super.onStop(), however that did not help me.
Any other ideas?
Thanks in advance for your help!
Why not do what the error suggests? If you move the call to the super class outside of your if-statement your app won’t crash on the second orientation change.