当前位置: 首页>>代码示例>>Java>>正文


Java OkHttpUtils.initClient方法代码示例

本文整理汇总了Java中com.zhy.http.okhttp.OkHttpUtils.initClient方法的典型用法代码示例。如果您正苦于以下问题:Java OkHttpUtils.initClient方法的具体用法?Java OkHttpUtils.initClient怎么用?Java OkHttpUtils.initClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.zhy.http.okhttp.OkHttpUtils的用法示例。


在下文中一共展示了OkHttpUtils.initClient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initialize

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
private static void initialize(boolean isHttps, InputStream[] online, InputStream loc, String password) {
    OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder();
    CookieJarImpl cookieJar = new CookieJarImpl(new PersistentCookieStore(context));
    HttpsUtils.SSLParams sslParams = null;
    if (isHttps) {
        sslParams = HttpsUtils.getSslSocketFactory(online, loc, password);
    }
    if (sslParams != null) {
        httpClientBuilder.sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager);
    }
    httpClientBuilder.connectTimeout(MAX_CONNECT_TIMEOUT, TimeUnit.MILLISECONDS)
            .readTimeout(MAX_READ_TIMEOUT, TimeUnit.MILLISECONDS);
    OkHttpUtils.initClient(httpClientBuilder.build());
    isInitialized = true;
    LogUtil.e("OkHttpClient初始化:支持Https = " + isHttps);
}
 
开发者ID:wzc25151,项目名称:lrs_android,代码行数:17,代码来源:HttpManager.java

示例2: onCreate

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();


    context = getApplicationContext();
    if (DEBUG == true) {
        CrashHandler crashHandler = CrashHandler.getInstance();
        crashHandler.init(getApplicationContext());
    }
    //  mQueue = Volley.newRequestQueue(getApplicationContext());

    cookieJar =
            new SimpleCookieJar(new SetCookieCache(),
                    new SharedPrefsCookiePersistor(getApplicationContext()));
    //  HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);


    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .cookieJar(cookieJar)
            .build();
    OkHttpUtils.initClient(okHttpClient);
    preferenceE = getSharedPreferences("overwall", MODE_PRIVATE).edit();
    preferenceR = getSharedPreferences("overwall", MODE_PRIVATE);

}
 
开发者ID:PlexPt,项目名称:overwall,代码行数:27,代码来源:App.java

示例3: onCreate

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .connectTimeout(10000L, TimeUnit.MILLISECONDS)
            .readTimeout(10000L, TimeUnit.MILLISECONDS)
            //其他配置
            .build();

    OkHttpUtils.initClient(okHttpClient);

    context = getApplicationContext();
}
 
开发者ID:lzmlsfe,项目名称:19porn,代码行数:15,代码来源:App.java

示例4: onCreate

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    context = this.getApplicationContext();
    Fresco.initialize(this);
    CookieJarImpl cookieJar1 = new CookieJarImpl(new MemoryCookieStore());
    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .connectTimeout(10000L, TimeUnit.MILLISECONDS)
            .readTimeout(10000L, TimeUnit.MILLISECONDS)
            .addInterceptor(new LoggerInterceptor("TAG"))
            .cookieJar(cookieJar1)
            .build();
    OkHttpUtils.initClient(okHttpClient);




    MultiDex.install(this);

    //开启debug模式,方便定位错误,具体错误检查方式可以查看http://dev.umeng.com/social/android/quick-integration的报错必看,正式发布,请关闭该模式
    //Config.DEBUG = true;

    initXY(context);
    //Thread.setDefaultUncaughtExceptionHandler(crashHandler);
    SharedPreferencesUtil.init(context,"deepSP",MODE_PRIVATE);
    /**
     * 初始化imageloader
     */
    ImageLoaderConfiguration configuration = ImageLoaderConfiguration.createDefault(this);
    ImageLoader.getInstance().init(configuration);
}
 
开发者ID:lwd1815,项目名称:Selector,代码行数:32,代码来源:MyApplication.java

示例5: onCreate

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
@Override
    public void onCreate() {
        super.onCreate();
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                .addInterceptor(new LoggerInterceptor("TAG"))
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                //其他配置
                .build();

        OkHttpUtils.initClient(okHttpClient);
    }
 
开发者ID:AlawnXu,项目名称:XMLBaseParser,代码行数:13,代码来源:BaseApplication.java

示例6: initialize

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
private void initialize() {
    instance = this;

    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .addInterceptor(new LoggerInterceptor("TAG-OKhttp-Pad"))
            .connectTimeout(10000L, TimeUnit.MILLISECONDS)
            .readTimeout(10000L, TimeUnit.MILLISECONDS)
            //其他配置
            .build();
    OkHttpUtils.initClient(okHttpClient);
    DisplayMetrics dm = getResources().getDisplayMetrics();
    width = dm.widthPixels;
    height = dm.heightPixels;
    DST_FOLDER_NAME = StorageUtils.getCacheDirectory(getApplicationContext()).getAbsolutePath();
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:16,代码来源:BApplication.java

示例7: onCreate

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
@Override
    public void onCreate() {
        super.onCreate();

        app = this;

        // 存放所有activity的集合
        mActivityList = new ArrayList<>();

        // 初始化app异常处理器 - 打包的时候开启
//        CrashHandler handler = CrashHandler.getInstance();
//        handler.init(getApplicationContext());

        // 初始化OkHttpUtils
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                //其他配置
                .build();
        OkHttpUtils.initClient(okHttpClient);

        // 初始化Fresco
        ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
                .setProgressiveJpegConfig(new SimpleProgressiveJpegConfig())
                .build();
        Fresco.initialize(this, config);

        // 初始化ShareSDK
        ShareSDK.initSDK(this);

        // 初始化JPush
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);

        // 更新用户登录状态
        UserBean.updateUserInfoFromNetwork(new UserBean.OnUpdatedUserInfoListener());

    }
 
开发者ID:6ag,项目名称:LiuAGeAndroid,代码行数:39,代码来源:App.java

示例8: onCreate

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
@Override
    public void onCreate()
    {
        super.onCreate();

        ClearableCookieJar cookieJar1 = new PersistentCookieJar(new SetCookieCache(), new SharedPrefsCookiePersistor(getApplicationContext()));

        HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);

//        CookieJarImpl cookieJar1 = new CookieJarImpl(new MemoryCookieStore());
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                .addInterceptor(new LoggerInterceptor("TAG"))
                .cookieJar(cookieJar1)
                .hostnameVerifier(new HostnameVerifier()
                {
                    @Override
                    public boolean verify(String hostname, SSLSession session)
                    {
                        return true;
                    }
                })
                .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
                .build();
        OkHttpUtils.initClient(okHttpClient);

    }
 
开发者ID:laotanggit,项目名称:okhttputils-masterlaotang,代码行数:29,代码来源:MyApplication.java

示例9: onCreate

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
@Override
    public void onCreate() {
        super.onCreate();
        INSTANCE = this;
        final Context mContext = this;
        DBUtils.getInstance().initDB(getApplicationContext());
        Stetho.initialize(Stetho.newInitializerBuilder(mContext)
                .enableDumpapp(new DumperPluginsProvider() {
                    @Override
                    public Iterable<DumperPlugin> get() {
                        return new Stetho.DefaultDumperPluginsBuilder(mContext)
                                .provide(new HprofDumperPlugin(mContext))
                                .finish();
                    }
                })
                .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(mContext))
                .build());
        Stetho.initializeWithDefaults(mContext);




        HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                .addInterceptor(new LoggerInterceptor("TAG"))
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                //其他配置
                .build();

        OkHttpUtils.initClient(okHttpClient);
    }
 
开发者ID:ZhuoKeTeam,项目名称:AndroidJsoup,代码行数:34,代码来源:IApplication.java

示例10: onCreate

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .connectTimeout(5000L, TimeUnit.MILLISECONDS)
            .readTimeout(5000L, TimeUnit.MILLISECONDS)
            .build();

    OkHttpUtils.initClient(okHttpClient);

}
 
开发者ID:iFlicker,项目名称:Solidot,代码行数:13,代码来源:Solidot.java

示例11: initOkHttpUtils

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
/**
 * 初始化网络请求
 */
private void initOkHttpUtils() {
    // Cookie
    CookieJarImpl cookieJar = new CookieJarImpl(new PersistentCookieStore(getApplicationContext()));
    // Https
    HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory(null, null, null);

    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .connectTimeout(10000L, TimeUnit.MILLISECONDS)
            .readTimeout(10000L, TimeUnit.MILLISECONDS)
            .sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager)
            .cookieJar(cookieJar)
            //其他配置
            .build();
    OkHttpUtils.initClient(okHttpClient);
    /**
     *  网络配置
     */
    NetWorkConfiguration configuration=new NetWorkConfiguration(this)
                                                        .baseUrl(NetWorkApi.baseUrl)
                                                        .isCache(true)
                                                        .isDiskCache(true)
                                                        .isMemoryCache(false);
    HttpUtils.setConFiguration(configuration);


}
 
开发者ID:ZhuoKeTeam,项目名称:MasterHelper,代码行数:30,代码来源:ZhuoKeApplication.java

示例12: init

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
private void init(){
        JPushInterface.init(getApplicationContext());
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                .addInterceptor(new LoggerInterceptor("TAG"))
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                //其他配置
                .build();

        OkHttpUtils.initClient(okHttpClient);
    }
 
开发者ID:woniukeji,项目名称:jianguo,代码行数:12,代码来源:Application.java

示例13: init

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
private void init(){
        JPushInterface.init(getApplicationContext());
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                .addInterceptor(new LoggerInterceptor("TAG"))
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                //其他配置
                .build();

        OkHttpUtils.initClient(okHttpClient);


}
 
开发者ID:woniukeji,项目名称:jianguo,代码行数:14,代码来源:Application.java

示例14: initOkHttp

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
private void initOkHttp() {
    OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .addInterceptor(new LoggerInterceptor("TAG"))
            .connectTimeout(5000L, TimeUnit.MILLISECONDS)
            .readTimeout(5000L, TimeUnit.MILLISECONDS)
            //其他配置
            .build();
    OkHttpUtils.initClient(okHttpClient);
}
 
开发者ID:yingLanNull,项目名称:MvpExample,代码行数:10,代码来源:MyApp.java

示例15: CheckVersionService

import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
public CheckVersionService() {
    OkHttpUtils.initClient(UnsafeOkHttpUtils.getClient());
}
 
开发者ID:ittianyu,项目名称:POCenter,代码行数:4,代码来源:CheckVersionService.java


注:本文中的com.zhy.http.okhttp.OkHttpUtils.initClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。