android json httppost方式联网

来源:互联网 发布:debian ubuntu哪个快 编辑:程序博客网 时间:2024/05/19 05:38


HttpPost request = new HttpPost(url);

StringEntity se = new StringEntity(param.toString());

request.setEntity(se);

HttpResponse httpResponse = new DefaultHttpClient().execute(request);//发送请求

如果出现java.net.SocketException: Permission denied这个异常,说明android目前还没有得到联网的权限,需要在AndroidManifest.xml中添加

<uses-permission android:name="android.permission.INTERNET" />

之后就可以正常连接了。

原创粉丝点击