My class asks for a context (for example, MainActivity
) as a parameter. Can I leave without context? just passing as a parameter to query ...
It looks like this:
public HttpTask(Context context, String query)
{
super();
this.context = context;
mHttpRequest = new HttpRequest(context, "https://services-dev.redetendencia.com.br", query);
}
@Override
protected Long doInBackground(String... params)
{
result = mHttpRequest.buscarSql();
return null;
}
@Override
protected void onPostExecute(Long aLong)
{
super.onPostExecute(aLong);
try {
((Interface) context).onQueryTaskExecute(result);
} catch (JSONException e) {
e.printStackTrace();
}
}
public interface Interface {
void onQueryTaskExecute(String result) throws JSONException;
}