Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Difference between new OkHttpClient() and new OkHttpClient.Builder()

 
Greenhorn
Posts: 18
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My question is two fold, so please co-operate.

First, I am new to these concepts so I am really confused between the above two.

Second, take a look at the part where I've already instantiated OkHttpClient and here I have to use the setConnectedTimeout and setReadTimeout methods. So what do I do next ? Any help will be greatly appreciated.

         
 
Rancher
Posts: 4801
50
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As it says in the Javadoc for OkHttpClient:
"
Use new OkHttpClient() to create a shared instance with the default settings ...
Or use new OkHttpClient.Builder() to create a shared instance with custom settings ...
"

The Builder allows you to build up your own version of the client.

As for what you do next, what do you want to achieve?
 
Debdeep Ganguly
Greenhorn
Posts: 18
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ohh thanks! Before going through the docs, I was implementing the the older version (without the custom Builder) due to which I was stuck. Thanks again btw.  
 
rubbery bacon. rubbery tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic