如何在 asynctask 后台调用两个不同的网络 url 并onPostExecute
分别调用?任何想法请帮助我。下面是我的代码,它适用于一个网络连接。在我的应用程序中有两个不同的网络连接。
public class TheTask extends AsyncTask<Void, String, String> {
@Override
protected void onPreExecute() {
super.onPreExecute();
}
@Override
protected String doInBackground(Void... arg0) {
try {
String query = URLEncoder.encode("American%20Cheese%20Burger", "utf-8");
String url = "http://198.57.208.46.xyz";
Log.i("url",""+url);
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
HttpEntity resEntity = response.getEntity();
_response=EntityUtils.toString(resEntity);
} catch(Exception e)
{
e.printStackTrace();
}
return _response;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
tv.setText(result);
}
}