Check the link here for reference .
Here you create a class: ExceptionHandler , which implements java.lang.Thread.UncaughtExceptionHandler ..
Inside this class, you will do your own things, saving lives, for example, by creating stacktrace and gettin, ready to load an error report, etc ...
Now comes the important part . That is how to catch this exception. Although it is very simple. Copy the following line of code into your every activity right after calling the super method in the override onCreate method.
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
Your activity might look something like this ...
public class ForceClose extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this)); setContentView(R.layout.main); } }
Hope this helps ...
CRUSADER May 15, '13 at 10:34 2013-05-15 10:34
source share