I have an android app that uses push. If the app receives a push message from the server it creates a push notification (with headline, message, icon) and presents it to the user.
normal case The click on the notification opens up an Activity (not the launcher) and the activity opens a fragment that shows content based on the notification. No magic here and everything works as expected.
the special/bad case If the device is inactive for at least 2h and you pick it up and click a notification that was pushed before, then it opens the Activity like in the normal case but no fragment comes up. Instead the launcher will be called.
While debugging this is time costly and frustrating I found out the following things. Maybe someone has an idea:
The Activity usually starts with an animation that I load from resources. I load and run it in onCreate(). If the Activity gets invoked by the push then the animation will be loaded but never runs. I bypassed this with a Handler that waits 2 seconds and checks if the animation listener was called. If not (bad case) then the handler calls the code to open the fragment.
opening the fragment caused a crash: IllegalStateException: Cannot perform this after onSaveInstanceState. Similar like here Exception java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState So I replaced commitAllowingStateLoss(). Now there is no crash anymore but the fragment does not appear. Only Fragment.newInstance() will be called but no onCreate() or any other lifecycle method.
Question: What crazy state is it that seems to break functions in my code after longer inactivity?
Device: I'm currently testing with a Nexus 5 with Android 6.0.1