• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

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.  
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic