java - Accessing 'this' in anonymous methods -
I am trying to do a simple global exception handler in your Android app and I am having troubles:
<> public class extends TicTacToe activity {/ ** when activity is created first. * / @ Override Crate on Public Zero (Bundle Saved Instantstate) {Super. Contents (Saved Instantstate); . Thread.currentThread () setUncaughtExceptionHandler (New UncaughtExceptionHandler () {@Override pre-qualified public void uncaughtException (yarn, throwing) {Toast.makeText (it, "toast", Toast.LENGTH_LONG);}}); SetContentView (R.layout.main); }}
I'm a rather new one with both Android and Java but that will work in .NET. Can I access the local variables of unknown methods in Java? If so, how should I rewrite it?
Thanks, Vitaly
You can, but not in the way Replace Also, you must have a compile-time error. It's not like this? This
UncaughtExceptionHandler
object
> TicTacToe.this
is known
Comments
Post a Comment