I have question regarding the option to automatically restart an android based app if an uncaught exception is fired causing the application to quit. My idea for implementing this request is as follows,
Create a PendingIntent in the OnCreate function of the MainLauncher. Would this PendingIntent point to a BroadCastReceiver in this case which could then fire off the MainLauncher Activity to restart the app?
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); restartIntent = PendingIntent.GetActivity(this, 0, new Intent(this, typeof(aBroadcastReceiverMaybe)), 0); }
Catch any uncaught exceptions for my app. My understanding is you could possibly override a function Thread.setDefaultUncaughtExceptionHandler() but this is in Java implementation for android. I am not quite sure how this works in under the xamarin framework
In the uncaught exception override, create an AlarmManager which will fire the PendingIntent from step 1 after 4 seconds. Force quit the app using an exit() function, again unsure of implementation under xamarin framework.
After 4 second delay in step 3, BroadcastReceiver will be notified. On Receiving notice, fire up MainLauncher Activity to restart app.
If there is a more suitable implementation for this task I would be happy to take onboard. Look forward to hearing from you soon.