r/android_devs • u/AlexoTheSealFlexo • Nov 22 '21
Coding Finally, I've found a valid use for "android:process" attribute for the activity - I've made a small library to trigger "safe mode" for application that experiences repeated crashes on startup
https://github.com/DrBreen/AppSalvager
10
Upvotes
4
u/AlexoTheSealFlexo Nov 22 '21
The inner workings of the library are very simple:
Install default exception handler before
ContentProviders start initializing (inApplication#attachBaseContext).On uncaught exception the exception is quickly serialized and saved to the disk
Every time it happens, we pass the list of recent exceptions to
SalvageModePolicy, which returnstrueif these exceptions should trigger salvage mode.If it returns true, launch
Activityin another process, and abortApplicationinitialization process early.ContentProvidercrashes will not happen here, since they are only initialized once during main process start.With this Activity, you can instruct user to reinstall the app, clear app data or do whatever else that can fix the repeated crash.