我有个问题。这是我的代码:
public String getXmlFromUrl(String url) {
String xml = null;
new Thread(new Runnable() {
@Override
public void run() {
try {
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
xml = EntityUtils.toString(httpEntity);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}).run();
// return XML
return xml;
}
那么,如何在我的 Thread 中使用 url 以及如何返回 xml?
谢谢您的帮助