本文整理汇总了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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例15: CheckVersionService
import com.zhy.http.okhttp.OkHttpUtils; //导入方法依赖的package包/类
public CheckVersionService() {
OkHttpUtils.initClient(UnsafeOkHttpUtils.getClient());
}