[英]Works with Android 2.2 but not Android 2.3
i make an app which accept xml data, but when i send query for this resource , looks that there is no connection . 我制作了一个接受xml数据的应用程序,但是当我发送对此资源的查询时,看起来没有连接。 I added android internet permissions and have net in browser but in my app there isn't any connection.
我添加了android互联网权限,并在浏览器中有网,但在我的应用程序中没有任何连接。
this is the code 这是代码
protected String sendRequest(String urlAdr,ArrayList postVars){ String data=extractPairValuesToString(postVars); urlAdr+=data; //send all variables in the url not from request properties String xmlResponse=null; HttpURLConnection con = null; URL url; try { url = new URL(urlAdr); con = (HttpURLConnection) url.openConnection(); //con.setReadTimeout(10000 /* milliseconds */); //con.setConnectTimeout(15000 /* milliseconds */); con.setRequestMethod("POST"); con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); con.setRequestProperty("Connection", "Keep-Alive"); con.setRequestProperty("Content-Length", ""+Integer.toString(data.getBytes().length)); con.setDoInput(true); con.setDoOutput(true); }catch (IOException e) { setErrorStatus(e.getMessage()); } }
More times than not, the manifest is missing: 清单多次丢失了:
<uses-permission android:name="android.permission.INTERNET"/>
See here: http://developer.android.com/resources/tutorials/views/hello-webview.html 请参见此处: http : //developer.android.com/resources/tutorials/views/hello-webview.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.