That's because in
(YahooWeatherInfoListener) this
this
refers to the AsyncTask
. Instead, you need to use:
(YahooWeatherInfoListener) HomeFragment.this
The cleaner way to implement this would be:
private class SearchByGPSTask extends AsyncTask<Void, Void, Void>{
private YahooWeatherInfoListener mListener;
public SearchByGPSTask( YahooWeatherInfoListener listener ) {
super();
mListener = listener;
}
@Override
protected void onPreExecute() {
}
@Override
protected Void doInBackground(Void... unused) {
mYahooWeather.setNeedDownloadIcons(true);
mYahooWeather.setSearchMode(SEARCH_MODE.GPS);
mYahooWeather.queryYahooWeatherByGPS(getActivity().getApplicationContext(), mListener );
return null;
}
protected void onPostExecute(Void unused) {
}
}
(note: Classes are generally uppercase, and better nouns -- "searchByGPS" sounds like a method, while "SearchByGPSTask" indicates that it's a class meant to do something.)