exception handling - how to implement uncaughtException android -
exception handling - how to implement uncaughtException android -
i found android: how auto-restart application after it's been "force closed"?
but don't know , how set alarm manager
thanks
you can grab uncaught exceptions in application extension class. in exception handler exception , seek set alarmmanager restart app. here illustration how in app, log exception db.
public class myapplication extends application { // uncaught exception handler variable private uncaughtexceptionhandler defaultueh; // handler listener private thread.uncaughtexceptionhandler _uncaughtexceptionhandler = new thread.uncaughtexceptionhandler() { @override public void uncaughtexception(thread thread, throwable ex) { // here logging of exception db pendingintent myactivity = pendingintent.getactivity(getcontext(), 192837, new intent(getcontext(), myactivity.class), pendingintent.flag_one_shot); alarmmanager alarmmanager; alarmmanager = (alarmmanager)getsystemservice(context.alarm_service); alarmmanager.set(alarmmanager.elapsed_realtime_wakeup, 15000, myactivity ); system.exit(2); // re-throw critical exception farther os (important) defaultueh.uncaughtexception(thread, ex); } }; public myapplication() { defaultueh = thread.getdefaultuncaughtexceptionhandler(); // setup handler uncaught exception thread.setdefaultuncaughtexceptionhandler(_uncaughtexceptionhandler); } }
android exception-handling
Comments
Post a Comment