Looks like force stop should prevent app from running and it\'s even disable all app\'s alarms. However I found that notification in Google Calendar still shown fine even after
I see two options there.
First one is to handle any exception via Thread.setDefaultUncaughtExceptionHandler() that is shipping with Java, it's not from Android SDK.
To be concise, you make your custom Application
class implement UncaughtExceptionHandler
and register it as a listener to any exception in the application. As soon as some crash happens this callback will be fired from where you can delay a job to happen in near future (e.g. spawn AlarmManager
to launch the app again in 50ms).
The second option is that you can launch your components in different processes. From docs:
android:process
The name of the process where the service is to run. Normally, all components of an application run in the default process created for the application. It has the same name as the application package. The element's process attribute can set a different default for all components. But component can override the default with its own process attribute, allowing you to spread your application across multiple processes.
A crash that happens on different process won't make the process that hosts your UI to crash.