Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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?

2 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.

alastair cooper
alastair cooper
28,204 Points

That is what the android docs are for