Skip to content Skip to sidebar Skip to footer

Error Java.lang.illegalstateexception: Activity Has Been Destroyed

Below I have been trying to work with the Facebook SDK while i came upon this problem, every time that a run the below code i seem to get the error 'java.lang.IllegalStateException

Solution 1:

Your onCreate is missing super.onCreate(savedInstanceState);, put it before the if statement and that should resolve the issue.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState == null) {
        // Add the fragment on initial activity setup
        mainFragment = new Fragment();
        getSupportFragmentManager().beginTransaction()
        .add(android.R.id.content, mainFragment).commit();
    } else {
        // Or set the fragment from restored state info
        mainFragment = (Fragment) getSupportFragmentManager()
                .findFragmentById(android.R.id.content);
    }

}

Post a Comment for "Error Java.lang.illegalstateexception: Activity Has Been Destroyed"