Showing a Toast using "setUncaughtExceptionHandler"
- by VitalyB
Hi everyone,
I'm trying to do a simple global exception handler in my Android app and I am having troubles:
public class TicTacToe extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Thread.currentThread().setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
Toast.makeText(this, "TOAST", Toast.LENGTH_LONG);
}
});
setContentView(R.layout.main);
}
}
I'm a rather new with both Android AND java but in .NET that would work. Can't I access local variable from anonymous methods in java? If so, how should I rewrite it?
Thanks,
Vitaly