Guest User

Untitled

a guest
Feb 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public class ActivityExceptionHandlerimplements Thread.UncaughtExceptionHandler {
  2.  
  3. private final Context mContext;
  4.  
  5. public ActivityExceptionHandler(Context context) {
  6. mContext = context;
  7. }
  8.  
  9. @Override
  10. public void uncaughtException(Thread t, Throwable e) {
  11. // logging code
  12. ...
  13. ...
  14.  
  15. // show error UI
  16. Intent intent = new Intent(mContext, GenericErrorActivity.class);
  17. intent.putExtra("error", e.toString());
  18. mContext.startActivity(intent);
  19.  
  20. android.os.Process.killProcess(android.os.Process.myPid());
  21. System.exit(0);
  22. }
  23.  
  24. }
  25.  
  26. Thread.setDefaultUncaughtExceptionHandler(new ActivityExceptionHandler(this));
Add Comment
Please, Sign In to add comment