1
My class asks for a context as a parameter (for example: MainActivity
). I can leave without the context? just passing the query as parameter...
Is this way:
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;
}
Related: https://answall.com/q/252765/64969
– Jefferson Quesado