【发布时间】:2013-09-20 07:30:54
【问题描述】:
我正在尝试从以下代码访问我的 uri
AsyncTask asyncTask = new AsyncTask() {
@Override
protected Object doInBackground(Object... params) {
AndroidHttpClient httpClient = AndroidHttpClient.newInstance("");
HttpUriRequest uriGetRequest = new HttpGet("http://localhost:8080/restsql-0.8.6/res/");
HttpResponse httpResponse = null;
try {
httpResponse = httpClient.execute(uriGetRequest);
;
} catch (Exception e) {
// TODO Auto-generated catch block
if(e!=null){
Log.e("ModelLoader", e.getMessage(), e);
}
Log.e("Model Loader", "Error while calling execute");
}
return httpResponse;
}
};
asyncTask.execute(new Object());
但 httpresponse 始终为空。甚至没有抛出异常。 我已经检查了像https://google.co.in/ 这样的有效uri,它工作正常。 我的浏览器 URI 也工作正常。 由于没有抛出异常,我无法继续进行。
【问题讨论】:
-
顺便说一句,如果您不需要任何参数,您可以使用 Void 扩展您的 AsyncTask,例如
AsyncTask<Void, Void, Void>
标签: android rest android-asynctask