• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Debdeep Ganguly
Greenhorn
Posts: 15
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • 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.

          
 
Dave Tolls
Ranch Hand
Posts: 2095
15
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 15
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • 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.  
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic