Error Performing stop of activity that is not resumed: on Android

1

Sometimes I get the following error

  

Performing stop of activity that is not resumed:

I have MainActivity that in the onCreate check if it is the first time the user opens the app to open another welcome activity OnBoarding and is when you press backspace or jump button, when the error appears.

protected void onCreate(Bundle savedInstanceState) {
...
Intent intent = new Intent(MainActivity.this, OnBoardingActivity.class);
startActivity(intent);
...
}

I think the error is that sometimes I do not allow time for MainActivity to be saved in the stack of the stack and when calling another activity immediately, when you want to go back there is no reference to anything.

    
asked by Webserveis 22.12.2016 в 20:59
source

1 answer

1

Starting with this answer in SO I have solved the Error or that seems to me, since it was very arbitrary. To call the activity put in onResumen but obviously this creates a loop when you leave the other activity and return to the general.

Using the library Once can be avoided:

@Override
protected void onResume() {
    super.onResume();

    Intent intent = new Intent(MainActivity.this, OnBoardingActivity.class);
    if (!Once.beenDone(Constants.COMPLETE_ONBOARDING)) {
        Log.d(TAG, "NO COMPLETE ONBOARDING ");
        if (!Once.beenDone(Once.THIS_APP_INSTALL,Constants.SHOW_ONBOARDING)) {
            Log.d(TAG, "NEED SHOW ONBOARDING");
            startActivity(intent);
        }
    }
}
    
answered by 22.12.2016 в 23:43