我有一个简单的类,它有一个调用 httpResponse 的方法,问题是当我从服务调用这个方法时它崩溃了,谁能帮我解决我的错误?
public class A(){
public String detailhtml(String Url, String params)
throws ClientProtocolException, IOException {
HttpGet httpGet = new HttpGet(Url + params);
HttpResponse httpResponse = new DefaultHttpClient().execute(httpGet);
// validar la respuesta http es correcta
if (httpResponse.getStatusLine().getStatusCode() == 200) {
String HtmlString = EntityUtils.toString(httpResponse.getEntity());
return HtmlString.trim();
} else {
return null;
}
}//
}
这是我崩溃的服务:
public class serviceHTTP extends Service {
public void onStart(Intent intent, int startId) {
String Rhtml= A.detailhtml(url, parametros);
}
}