0

My app uses a pagerTabStrip with fragments. When the app goes to background and other memory intensive tasks run in foreground, the app will be killed. Then, if I recall the app, the fragments buttons onclick methods dont fire anymore. (side note: the color of the buttons is then wrong too, but the "visual click" down->up is working)

It is working fine when I manually kill the app or when it's just short term via onPause/onResume in background. It seems that in this system-kill-case sort of image of the app is taken and reloaded (incorrect).

If there is no direct way to fix this, I would like to catch this event, to just recreate the whole fragment, but I can't. I tried onTrimMemory and investigated the call order of onStop/onDestroy/onRestart ... but I couldnt figure out, when this "special kill" happens.

Thank you!

Max Power
  • 169
  • 10

1 Answers1

0

Got it.

First, to reproduce the issue, just launch the app, send to background and then hit the red circle-cross at the left pane of the logcat output frame in android studio as described here:

https://medium.com/inloopx/android-process-kill-and-the-big-implications-for-your-app-1ecbed4921cb

My workaround is to save the processID in onSaveInstanceState and to check if this changed in onCreate as described here:

https://stackoverflow.com/a/47483856/6053524

If so, the app has been killed by system and my issues of not proper working UI occured. To fix this I load the initial Activity via new Intent/startActivity to get a clean new application.

Max Power
  • 169
  • 10