没事
来源:互联网 发布:js object 长度 编辑:程序博客网 时间:2024/06/02 10:16
package zhangyapeng.bwie.com.eggplantdoctor;import android.app.Application;import zhangyapeng.bwie.com.eggplantdoctor.base.network.Singleton;/** * Created by zhang on 2017/1/9. */public class Qz extends Application { public static Singleton singleton; @Override public void onCreate() { super.onCreate(); singleton = Singleton.getInStance(); }}
/////////////////////////////////////////////////////////////////////////
import android.app.Application;import zhangyapeng.bwie.com.recycleview.okhttp.Singon;/** * Created by zhang on 2017/2/5. */public class Qz extends Application { public static Singon singleton; @Override public void onCreate() { super.onCreate(); singleton = Singon.getInStance(); }}
//////////////////////////////////////////////////////
package zhangyapeng.bwie.com.recycleview.okhttp;import android.os.Message;import android.telecom.Call;import com.google.gson.Gson;import com.squareup.okhttp.Callback;import com.squareup.okhttp.OkHttpClient;import com.squareup.okhttp.Request;import com.squareup.okhttp.Response;import java.io.IOException;/** * Created by zhang on 2017/2/5. */public class Singon { private static volatile Singon singleton; private final Gson gson; private Singon() { gson = new Gson(); } public static Singon getInStance() { if (singleton == null) { synchronized (Singon.class) { if (singleton == null) { singleton = new Singon(); } } } return singleton; } public void netWork(String url, final MyHandler handler){ //创建okHttpClient对象 OkHttpClient mOkHttpClient = new OkHttpClient(); //创建一个Request final Request request = new Request.Builder() .url(url) .build(); //new call com.squareup.okhttp.Call call = mOkHttpClient.newCall(request); //请求加入调度 call.enqueue(new Callback() { @Override public void onFailure(Request request, IOException e) { Message obtain = Message.obtain(); obtain.what=0; handler.sendMessage(obtain); } @Override public void onResponse(final Response response) throws IOException { String json = response.body().string(); Message obtain1 = Message.obtain(); obtain1.what = 2; obtain1.obj = json; handler.sendMessage(obtain1); } }); }}
0 0
- 没事
- 没事
- 没事
- 没事
- 今天没事
- 没事闲聊!
- 最近没事...
- 没事走两步......
- 没事玩玩
- 没事逛书城
- 没事写写
- 没事投乐呀
- 没事写两句
- 没事扯两句
- 没事想想
- 没事笑一笑
- 没事偷着乐!
- 没事找抽型
- 后台的activity被系统自动回收的话,怎么在回到界面的时候恢复数据
- GRE-D
- 通讯录 (纯数据库操作)
- dubbo+zookeeper环境搭建
- Java数组中常见的排序算法
- 没事
- MaxIO智能缓存加速技术
- 2017寄语
- Spring IOC 的原理概述
- KDE的使用总结/C++码源心得
- Head First_设计模式_策略模式
- win10装机指南
- 关于表单
- 星球大战 JSOI2008 并查集