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
3,068 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
25,405 Points

That is what the android docs are for