参考博客:Android HttpURLConnection 基础使用
参考博客:Android访问网络,使用HttpURLConnection还是HttpClient?
String getUrl = mUrl + "/login.ashx?type=authen&user=" + mEmail + "&pwd=" + mPassword; URL loginUrl = null; InputStream in = null; HttpURLConnection conn = null; try { loginUrl = new URL(getUrl); conn = (HttpURLConnection) loginUrl.openConnection(); in = new BufferedInputStream(conn.getInputStream()); Scanner scanner = new Scanner(in).useDelimiter("\\A"); String result = scanner.hasNext() ? scanner.next() : ""; Log.e("Url请求", result); } catch (IOException ex){ Log.e("Url请求 错误!", ex.toString()); } return false;
GET请求模式