android json httppost方式联网


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" />

之后就可以正常连接了。

你可能感兴趣的:(android,json,url)