Created
April 11, 2013 09:35
-
-
Save daichan4649/5362013 to your computer and use it in GitHub Desktop.
set UncaughtExceptionHandler (for Android)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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