try this custom Handler:
class H extends Handler {
public H(Looper looper) {
super(looper);
}
@Override
public void dispatchMessage(Message msg) {
// catch any Exception
try {
super.dispatchMessage(msg);
} catch (Exception e) {
Log.d(TAG, "dispatchMessage " + e.getMessage());
}
}
}
testing code:
HandlerThread ht = new HandlerThread("hthread");
ht.start();
Handler h = new H(ht.getLooper());
Runnable r = new Runnable() {
@Override
public void run() {
throw new RuntimeException("testing exception");
}
};
h.post(r);
h.post(r);