Cannot resolve method getApplicationContext()

The trouble is that you are calling getApplicationContext() inside a Class that does not extend Context or its subclasses (Activity, etc). You should pass Context or its subclass to the JSONTask constructor. Furthermore, I don’t see where you are initializing lvMovies – and you are likely to get NullPointerException at lvMovies.setAdapter(adapter); – my suggestion is that you should pass this as well to your JSONTask constructor:

private Context mContext;
private ListView lvMovies;
public JSONTask (Context context, ListView  lstView){
   this.lvMovies = lstView;
   this.mContext = context;
} 

so that in the onPostExecute you can do something like:

MovieAdapter adapter = new MovieAdapter(mContext,R.layout.row,result);
lvMovies.setAdapter(adapter);

I hope this helps.

Leave a Comment