I\'m trying to raise a toast from asynctask, but I\'m having trouble getting my parameters right. I\'m toasting from onProgressUpdate, so I\'m on the UI thread, which I thi
You can NOT do this in onProgressUpdate(). At least not this way. If Eclipse gives you this error, it is because MainActivity.this is unresolvable for it. Why? Because you are NOT in the UI Thread, so what you do is not thread-safe, because you must not access UI from another Thread.
First of all, and as told before, you should write a constructor taking a context and saving it to a global variable, so it is accessible everywhere inside the class. Then, to access UI in a thread-safe way, use one of the following:
Activity.runOnUiThread(Runnable)
View.post(Runnable)
View.postDelayed(Runnable, long)
Those are thread-safe.
Regards