Question

I am using a WebView in my app's sole Activity. Whenever the user clicks on the BACK button, I override the onKey and process some clean up before calling finish of the activity.

I see that once in a while (maybe 1 out of 20 times), onDestroy is not called. And in this case, if I launch my app again, a blank screen comes up. The Activity's onCreate is not called, and neither is my overridden Application's onCreate.

Does anyone know why this happens, and are there any possible solutions?

Thanks,
Rajath

Was it helpful?

Solution 2

It turns out that I was capturing uncaught exceptions using the UncaughtExceptionHandler(). So, sometimes when the app was actually crashing in onDestroy(), the subsequent session was not properly launched.

Of course, in the case where the app's onDestroy() was not called at all, the problem is still fixed when I don't use UncaughtExceptionHandler(). Not sure why though.

-Rajath

OTHER TIPS

Based on the little less than a line of code you have provided, please do the following:

  1. Stop overriding back key.
  2. Do the cleanup elsewhere, e.g., in onPause().
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top