android - How do I start another activity from UncaughtExceptionHandler.uncaughtException() method? -


possible duplicate:
using global exception handling “setuncaughtexceptionhandler” , “toast”

i have implemented uncaughtexceptionhandler in oncreate() in 1 of activities.

in uncaughtexception() method trying open activity erroractivity parameter (error msg , stacktrace). activity should show (ment globaly) alertdialog , handle logs etc.

can 1 tell me why erroractivity doesnt open while code in oncoughtexception gets executed? suspect problem thread related.

here first activity (simulating exception in oncreate())

public class mainactivity extends activity {      globalsettings settings;      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          thread.currentthread().setuncaughtexceptionhandler(                 new uncaughtexceptionhandler() {              @override             public void uncaughtexception(thread thread, throwable ex) {                 intent intent = new intent(mainactivity.this,                                                erroractivity.class);                 bundle bundle = new bundle();                 bundle.putstring("error", ex.getmessage());                 intent.putextras(bundle);                 startactivity(intent);              }          } );          settings = (globalsettings) getapplication();         settings = null;         settings.getapplicationcontext();         setcontentview(r.layout.main);     } } 

and second activity should handle errors:

public class erroractivity extends activity {      @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);          bundle bundle = getintent().getextras();         string name = bundle.getstring("error");         showalertdialog(name);     } } 

refer using global exception handling “setuncaughtexceptionhandler” , “toast”

there qberticus told

you're not seeing because exception happened on ui thread , stack unrolled way. there no more looper , there no support there used display toast.

since exception happens on ui cannot ui operation :(


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

c# - SharpSVN - How to get the previous revision? -

php cli reading files and how to fix it? -