List of usage examples for twitter4j AlternativeHttpClientImpl getOkHttpClient
public OkHttpClient getOkHttpClient()
From source file:com.github.moko256.twitlatte.GlobalApplication.java
License:Apache License
private static void replaceCompatibleOkHttpClient(Configuration conf) { if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) { AlternativeHttpClientImpl httpClient = getT4jHttpClient(conf); OkHttpClient oldClient = httpClient.getOkHttpClient(); if (!(oldClient.sslSocketFactory() instanceof SSLSocketFactoryCompat)) { try { X509TrustManager trustManager = systemDefaultTrustManager(); Field field = AlternativeHttpClientImpl.class.getDeclaredField("okHttpClient"); field.setAccessible(true); field.set(httpClient, oldClient.newBuilder() .sslSocketFactory(new SSLSocketFactoryCompat(trustManager), trustManager).build()); } catch (NoSuchFieldException | IllegalAccessException | NoSuchAlgorithmException | KeyStoreException e) { e.printStackTrace();/*from w w w . j a v a 2 s . co m*/ } } } }