Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Weather App Networking Making an HTTP GET Request with OkHttp

alexander` bourne
alexander` bourne
1,568 Points

As a developer how am i supposed to know that i have to use so many methods on a particular object?? example below

what im trying to ask is quite simple, this is a tutorial so i know which methods to use since the teacher is using them, im simply copying them and if explanation is being given im understanding them. BUT i cannot figure out how to know that myself? For example in the video the teacher used this,

Request request = new Request.Builder.url(projectUrl).build;

now as a developer i may have to deal with new APIs for every app, how will i know that i have to create a request object and then use the Builder method on that object and then the url method and give a specific input and then use the build method.

Also, i dont even have an idea about the sequence!, the teacher used the sequence of making a request object and then a call object and then calling the newCall method and then the response method like this:

Request request = new Request.Builder.url(projectUrl).build; Call call = client.newCall(request); Response response = ((Call) call).execute();

bottom line, my question is, how will i know what to do as a developer when theres no teacher to tell me which methods/objects/sequence i should use?

3 Answers

Blake Harmon
Blake Harmon
4,876 Points

The info is coming from the recipe section in the gitHub OkHttp wiki, under "Synchronous Get" and the code that follows it.

I wanted to ask the same question but it is already answered, thank you

alastair cooper
alastair cooper
30,617 Points

That is what the android docs are for