Skip to content

Instantly share code, notes, and snippets.

@daichan4649
Created April 11, 2013 09:35
Show Gist options
  • Save daichan4649/5362013 to your computer and use it in GitHub Desktop.
Save daichan4649/5362013 to your computer and use it in GitHub Desktop.
set UncaughtExceptionHandler (for Android)
@Override
public void onCreate(Bundle savedInstanceState) {
Thread.setDefaultUncaughtExceptionHandler(uncaughtExceptionHandler);
}
/** UncaughtExceptionHandler */
private UncaughtExceptionHandler uncaughtExceptionHandler = new UncaughtExceptionHandler() {
private UncaughtExceptionHandler originalUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
@Override
public void uncaughtException(Thread thread, Throwable throwable) {
//TODO 内部終了処理(toast等の表示は不可)
// 正常にプロセスkillさせる
originalUncaughtExceptionHandler.uncaughtException(thread, throwable);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment