Android: Catching uncaught exception, sending stacktrace to server, and still using default behavior -
is doing of in 1 possible? can't seem work. how catching uncaught exceptions:
public class myapplication extends application { private uncaughtexceptionhandler defaulthandler; public void oncreate() { defaulthandler = thread.getdefaultuncaughtexceptionhandler(); // setup handler uncaught exceptions thread.setdefaultuncaughtexceptionhandler(new thread.uncaughtexceptionhandler() { @override public void uncaughtexception(thread thread, throwable e) { handleuncaughtexception(thread, e); } }); } public void handleuncaughtexception(thread thread, throwable e) { intent crashreportintentservice = new intent(this, sendcrashreportintentservice.class); author writer = new stringwriter(); printwriter printwriter = new printwriter(writer); e.printstacktrace(printwriter); string s = writer.tostring(); crashreportintentservice.putextra(sendcrashreportintentservice.stack_trace, s); startservice(crashreportintentservice); defaulthandler.uncaughtexception(thread, e);// allow default handle , crash app } }
so grab it, stack trace, effort fire off service. after phone call startservice phone call defaulthandler.uncaughtexception() default "unfortunately app has crashed" message pop up. however, seems service never called.
this part of service looks like:
@override protected void onhandleintent(intent intent) { log.i(tag, "***** sendcrashreportintentservice: in onhandleintent!"); handleuncaughtexception(intent.getstringextra(stack_trace)); }
i have breakpoints never called , i'm getting no hits in database.
android exception android-service uncaught-exception
No comments:
Post a Comment