An interesting case, if you are debugging life cycle methods, you can see that onStop is called when the screen is onStop , without onPause . Then the failure is recorded
java.lang.RuntimeException: Performing pause of activity that is not resumed: MainActivity
followed by
java.lang.RuntimeException: Performing stop of activity that is not resumed: MainActivity
I assume this is a structure error. Interestingly, this only happens with the flag FLAG_ACTIVITY_REORDER_TO_FRONT .
From the moment of writing, I just found this post that clearly shows that there seems to be a major flaw in this flag: Is there an alternative to Intent.FLAG_ACTIVITY_REORDER_TO_FRONT (notification mentioned by Android Bug Ticket)
Workaround: If you depend on the behavior FLAG_ACTIVITY_REORDER_TO_FRONT gives you and you want to simulate it (sort), you can use
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
instead (however, it works slightly differently - it clears the stack on top of the called activity, rather than reordering it, so you will have at least 1 re-creation of the activity).
Another option is to work around the launchMode attribute in the activity definition in the manifest. launchMode="singleInstance" may be what you need (however, this is useless with your task stack, so be careful)
After all, if your design allows this, consider snippets to avoid these problems altogether.
source share