public static OkHttpClient createOkHttpClient ( ) { OkHttpClient okHttpClient = new OkHttpClient ( ) ; // set timeouts okHttpClient . setConnectTimeout ( 15 * 1000 , TimeUnit . MILLISECONDS ) ; okHttpClient . setReadTimeout ( 20 * 1000 , TimeUnit . MILLISECONDS ) ; return okHttpClient ; }
Create an OkHttpClient with sensible timeouts for mobile connections .