我想从服务 url 读取 xml,我写了代码,我的 url 没问题,从浏览器看,
public String getXML(){
String line = null;
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpPost = new HttpGet("http://localhost/simplewebservice/index.php?user=1");
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
line = EntityUtils.toString(httpEntity);
} catch (Exception ex) {
Log.d("Error reading xml", ex.toString());
}
return line;
}
但它给了我以下错误 java.net.SocketException: Permission denied
。
谁能对此有更好的解决方案?
亲切的问候,
普里托姆。
最佳答案
在您的 manifest.xml 中添加此描述
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
关于android - 使用android从php webservice url获取xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8680457/