初试OkHttp

package cgg.com.scg.Utils;

import android.util.Log;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * author: shichenguang
 * date:   2018/1/3 11:54
 * email:  none
 */

public class NetUtls {
    public static void getJsonFormNet(String url){
        // 创建okHttpClient
        OkHttpClient okHttpClient = new OkHttpClient();
        // 获取请求对象
        final Request request = new Request.Builder().url(url).build();
        // 获取Call
        Call call =okHttpClient.newCall(request);
        // 执行请求
        call.enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {// 失败回调
                Log.e("TAG",e.getMessage().toString());
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                Log.e("TAG",response.body().string());
            }
        });

    }
}
01-03 13:58:01.784 1512-1546/cgg.com.scg D/dalvikvm: GC_FOR_ALLOC freed 151K, 8% free 3220K/3472K, paused 9ms, total 10ms
01-03 13:58:01.784 1512-1546/cgg.com.scg E/TAG: <!DOCTYPE html>
                                                <html>
                                                  <head>
                                                    <link rel="canonical" href="http://blog.csdn.net/wanderer_ankey/article/details/78827822"/> 
                                                    <script type="text/javascript">
                                                        var username = "wanderer_ankey";
                                                        var _blogger = username;
                                                        var blog_address = "http://blog.csdn.net/wanderer_ankey";
                                                        var static_host = "http://csdnimg.cn/release/phoenix/";
                                                        var currentUserName = ""; 
                                                        var fileName = '78827822';
                                                        var commentscount = 0;
                                                        var islock = false
                                                        window.quickReplyflag = true;
                                                        var totalFloor = 0;
                                                        var isBole = false;
                                                        var isDigg = false;
                                                        var isExpert=false;
                                                        var isAdm = false;
                                                    </script>
                                                    <meta http-equiv="content-type" content="text/html; charset=utf-8">
                                                    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
                                                    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
                                                    <meta name="apple-mobile-web-app-status-bar-style" content="black">
                                                    <script src="http://c.csdnimg.cn/public/common/libs/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
                                                    <link rel="stylesheet" href="http://c.csdnimg.cn/public/common/libs/bootstrap/css/bootstrap.min.css">
                                                    <link rel="stylesheet" href="http://c.csdnimg.cn/public/static/css/avatar.css">
                                                    <link rel="stylesheet" href="http://csdnimg.cn/release/phoenix/production/main-42ec361b19.css">
                                                    <link rel="stylesheet" href="http://c.csdnimg.cn/public/common/toolbar/content_toolbar_css/content_toolbar.css">
                                                
                                                    <script src="http://csdnimg.cn/rabbit/exposure-click/main-1.0.5.js"></script>
                                                    <script type="text/javascript" src="http://csdnimg.cn/pubfooter/js/tracking-1.0.2.js" charset="utf-8"></script>
                                                    <script type="text/javascript" src="http://csdnimg.cn/release/phoenix/production/main-fff0aba365.js"></script>
                                                
                                                    <script src="http://dup.baidustatic.com/js/ds.js"></script>
                                                    <script type="text/javascript">
                                                        // Traffic Stats of the entire Web site By baidu
                                                        var _hmt = _hmt || [];
                                                        (function() {
                                                            var hm = document.createElement("script");
                                                            hm.src = "https://hm.baidu.com/hm.js?6bcd52f51e9b3dce32bec4a3997715ac";
                                                            var s = document.getElementsByTagName("script")[0];
                                                            s.parentNode.insertBefore(hm, s);
                                                        })();
                                                        // Traffic Stats of the entire Web site By baidu end
                                                    </script>
                                                    <meta name="description" content="regedit 注册表运行命令
                                                
                                                cmd打开DOS窗口
                                                
                                                SnippingTool 打开截图工具
                                                
                                                calc.exe打开计算器
                                                
                                                shutdown -s -t 3600 定时关机,参数有间有空格,-t 后为关机倒计时秒数 shutdown -a 如果中途想取消定时关机
                                                
                                                cleanmgr 打开系统自带磁盘清理器
                                                
                                                msconfig 管理启动项
                                                
                                                control 打开控制" />
                                                    <meta name="keywords" content="" />
                                                    <meta http-equiv="Cache-Control" content="no-siteapp" /><link rel="alternate" media="handheld" href="#" />
                                                    <meta name="shenma-site-verification" content="5a59773ab8077d4a62bf469ab966a63b_1497598848">
                                                    <title>win10dos命令 - CSDN博客</title>
                                                    <link href="http://csdnimg.cn/public/favicon.ico" rel="SHORTCUT ICON">
                                                </head>
                                                <body>
                                                <script id="toolbar-tpl-scriptId" prod="download" skin="black" src="http://c.csdnimg.cn/public/common/toolbar/js/content_toolbar.js" type="text/javascript" domain="http://blog.csdn.net/"></script>
                                                <div class="container clearfix">
                                                  <main>
                                                    <article>
                                                        <h1 class="csdn_top">win10dos命令</h1>
                                                        <div class="article_bar clearfix">
                                                            <div class="artical_tag">
                                                                <span class="original">
                                                                原创                </span>
                                                                <span class="time">2017年12月17日 20:55:11</span>
                                                            </div>
                                                
                                                            <ul class="article_tags clearfix csdn-tracking-statistics tracking-click" data-mod="popu_377" >
                                                                <li class="tit">标签:</li>
                                                
                                                <!--          [startarticletags]-->
                                                                <!--          [endarticletags]-->
                                                            </ul>
                                                            <ul class="right_bar">
                                                                <li><button cla
01-03 13:58:01.805 1512-1512/cgg.com.scg W/EGL_genymotion: eglSurfaceAttrib not implemented
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值