码迷,mamicode.com
首页 > 移动开发 > 详细

Android --http请求之HttpURLConnection

时间:2015-09-18 09:21:36      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:

参考博客: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请求模式

Android --http请求之HttpURLConnection

标签:

原文地址:http://www.cnblogs.com/bmbh/p/4818211.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!