android 网络请求 HttpClient (已经被弃用)

HttpClient httpClient = new DefaultHttpClient();

GET 请求

HttpGet httpGet = new HttpGet(https://www.ietf.org/rfc/rfc2616.txt");

httpClient.execute(httpGet)

POST 请求

HttpPost httpPost = new HttpPost("https://www.ietf.org/rfc/rfc2616.txt"");

List<NameValuePair> params = new ArrayList<NameValuePair>();

params.add(new BasicNameValuePair("username","admin"));

params.add(new BasicNameValuePair("password","123456"));

UrlEncodedFormEntity entity = new UrlEncodedFormEntity("params","uft-8");

猜你喜欢

转载自blog.csdn.net/weixin_41069726/article/details/89813716
今日推荐