Maria Hientono
Maria Hientono

Reputation: 193

Screen Orientation Changing Handler fails in TabActivity

I am developing an Android application with a TabHost in it SDK 7.

My problem is the screen orientation changing handler fails to do the job. This is the scenario:

What I mean by “fail” to update the screen is:

This is the method that I used:

Any suggestion or a workaround for my problem? I will appreciate and try every suggestion. Thank you :D

Upvotes: 1

Views: 344

Answers (1)

Kevin Coppock
Kevin Coppock

Reputation: 134714

Your solution should be to handle configuration changes properly. Using configChanges is only an optimization for very edge case situations, but you still need to be prepared for the case when your Activity state is saved and your Activity destroyed to relieve memory pressure.

In your Activity:

@Override
public void onSaveInstanceState(Bundle outState) {
    // Put any temporary state for this Activity instance
    // into the outState bundle
}

Then in onCreate():

@Override
public void onCreate(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        // Retrieve and reassign any state that you saved
    }
}

Also see Handling Runtime Changes

Upvotes: 0

Related Questions