When my AsyncTask finishes, I display info in a TextView.
@Override protected void onPostExecute(Void x)
{
MainActivity.lblLastLetterProcessed.setText("A-Z loaded");
}
Like so:
public static void setLastLetterProcessed(char c){
lblLastLetterProcessed.setText("" + c);
}
I'd rather give the info via Toast but Toast requires Context.
protected void onPostUpdate(Integer... progress)
{
Toast toast= Toast.makeText(???????????, "Loaded A-Z", Toast.LENGTH_LONG);
toast.show();
}
So I wrote popupMessage:
void popupMessage(String text)
{
SpannableStringBuilder altText = new SpannableStringBuilder(text);
altText.setSpan(new ForegroundColorSpan(0xFFCC5500), 0, altText.length(), 0);
int duration = Toast.LENGTH_SHORT;
Context context = getApplicationContext();
Toast toast = Toast.makeText(context, altText, duration);
toast.setGravity(Gravity.TOP | Gravity.CENTER, 0, 0);
toast.show();
}
But I can't call it from onPostUpdate since popupMessage is NOT static.
If I make it static, I can't use getApplicationContext. And if I add Context as a parameter, I can't pass Context from onPostUpdate.
Googling has provided no SO Answers I can implement.
What can I do?