I'm trying to use this code from "Android Recipes":
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("FetchAndPopTask.doInBackground exception");
builder.setMessage(e.getMessage());
builder.setPositiveButton("OK", null);
builder.create().show();
...but don't know what I should replace "context" with. I've tried the .java file's class, the immediate class, and "this" but none of them compile.
In more context, the code is:
public class SQLiteActivity extends ActionBarActivity {
private FetchAndPopTask _fetchAndPopTask;
. . .
private class FetchAndPopTask extends AsyncTask<String, String, String> {
@Override
protected String doInBackground(String... params) {
. . .
try {
. . .
} catch (Exception e) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); // <= "context"...?
builder.setTitle("If I go blind, I'll use a Service Platypus (instead of a Service Dog)");
builder.setMessage(e.getMessage());
builder.setPositiveButton("OK", null);
builder.create().show();
return result;
}
I tried all of the following:
AlertDialog.Builder builder = new AlertDialog.Builder(SQLiteActivity);
AlertDialog.Builder builder = new AlertDialog.Builder(FetchAndPopTask);
AlertDialog.Builder builder = new AlertDialog.Builder(this);
...but none compile; so what does "context" need to be here?