android 登录判断
16lz
2021-12-04
public void login() { String target = "http://192.168.1.77/android/json_users/login_users.aspx"; HttpPost httprequest = new HttpPost(target); List<NameValuePair> paramsList = new ArrayList<NameValuePair>(); paramsList.add(new BasicNameValuePair("user_name", EditText1.getText() .toString())); paramsList.add(new BasicNameValuePair("password", EditText2.getText() .toString())); try { httprequest .setEntity(new UrlEncodedFormEntity(paramsList, "UTF-8")); HttpClient HttpClient1 = new DefaultHttpClient(); HttpResponse httpResponse = HttpClient1.execute(httprequest); if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { result = EntityUtils.toString(httpResponse.getEntity()); } else { result = "请求失败"; } Toast.makeText(LoginActivity.this, result, Toast.LENGTH_SHORT) .show(); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
更多相关文章
- Android(安卓)网络请求不能放在主线程上面
- Android(安卓)Studio编译失败:java.util.concurrent.ExecutionExc
- Android微信支付回调类
- Android(安卓)Studio编译失败:java.util.concurrent.ExecutionExc
- Android文件下载
- Android(安卓)handler异步更新
- Android(安卓)HttpClient网络通信
- android http请求
- Android(安卓)Studio编译失败: java.util.concurrent.ExecutionEx