I have a very simple Thread.IUncaughtExceptionHandler
as following
public class AirExceptionHandler : Java.Lang.Object, Thread.IUncaughtExceptionHandler
{
public static readonly string TAG = "AirExHandler";
private MainActivity activity;
private Thread.IUncaughtExceptionHandler defaultUEH;
public AirExceptionHandler(MainActivity activity)
{
Log.Info(TAG, "Initialised");
this.activity = activity;
this.defaultUEH = Thread.DefaultUncaughtExceptionHandler;
}
public void SetActivity(MainActivity activity)
{
this.activity = activity;
}
public void UncaughtException(Thread t, Throwable e)
{
Log.Info(TAG, "Force Closed");
JavaSystem.Exit(0);
}
}
In my Mainactivity
, I am doing the following to initialise it in OnCreate
private static Handlers.AirExceptionHandler _unCaughtExceptionHandler;
.........
if (_unCaughtExceptionHandler == null)
_unCaughtExceptionHandler = new Handlers.AirExceptionHandler(this);
else
_unCaughtExceptionHandler.SetActivity(this);
if (Thread.DefaultUncaughtExceptionHandler != _unCaughtExceptionHandler)
Thread.DefaultUncaughtExceptionHandler = (_unCaughtExceptionHandler);
I can see Log.Info(TAG, "Initialised");
triggered but when I force close my app, the UncaughtException
does not get trigger
What am I doing wrong?