OkHttp 3 IntegrationΒΆ

To use OkHttp3 with Neumob SDK, use Neumob.createOkHttp3Client() method to create an instance of OkHttpClient.

  1. To create an instance with default settings, use
OkHttpClient client = Neumob.createOkHttp3Client();

instead of calling OkHttp API as below:

OkHttpClient client = new OkHttpClient();
  1. To create an instance with custom settings use a Builder object as below
OkHttpClient.Builder builder = new OkHttpClient.Builder()
    .addInterceptor(new HttpLoggingInterceptor())
    .cache(new Cache(cacheDir, cacheSize));

OkHttpClient client = Neumob.createOkHttp3Client(builder);

instead of calling OkHttp API as below:

OkHttpClient.Builder builder = new OkHttpClient.Builder()
    .addInterceptor(new HttpLoggingInterceptor())
    .cache(new Cache(cacheDir, cacheSize));

OkHttpClient client = builder.build();