Pramod mishra
Pramod mishra

Reputation: 625

After screen orientation change activity class member variable(Object) loss

I have a base class for managing fragment inside my Activity. which handles fragment backstack,opening etc. but on Orientation change this object become null and i loss all my fragment state.

public class Dashboard extends AbstractNavDrawerActivity implements AsyncRequest
    .OnAsyncRequestComplete {

BaseFragmentOrganizer fragmentOrganizer;//object that manages backstack and other operation 


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
//on orientation change fragmentOrganizer becomes null so no more backstack.
    if (savedInstanceState == null) {
        fragmentOrganizer = new MainFragmentOrganizer(getSupportFragmentManager());
    }

Upvotes: 0

Views: 341

Answers (1)

V-rund Puro-hit
V-rund Puro-hit

Reputation: 5534

You just have to add android:configChanges="orientation|screenSize" to your Activity in manifest file.

it won't recreate your Activity.

Upvotes: 2

Related Questions