2018, Mar 21
In your ever day tasks, on web, you request (Query) for something either
by clicking some links or entering some link. You get a response.
Basically, You Query from some Client (Mobile/Laptop]. You Get response
from Server (Google/Twitter/Facebook), which is serving your Query
(called Web Services).
When you get a Response, data is in a particular format chosen by the Server.
Like, JSON, XML. This data is then extracted/converted and is
updated to UI of your application (Like Twitter/fb)
3 sub topics to cover these include:
- Whats in http link.
- HTTP Networking (Send & Receive)
- JSON (Parsing)
Whats in http link.
Entering/Quering “google io” in youtube search bar, is same as forming
the below link with Query information.
https: is Protocol/Scheme.
www.youtube.com is Host/Domain/Authority.
results is Resource Path.
?search_query=Google+io is Query.
Query starts with
? and if you notice its a key/value pair.
Here in this link, Key is search_query; Value is Google+io.
Similary, Read this link. It has 2 Key-Value pairs.
Enter the link and see the response you get. Use JSON Formatter online,
to see the response in a cleaner way. Like JSON Pretty print,
Its exchange of Communication that happends between Computers.
Steps involved are:
Form HTTP Request
- Send the Request
Most commonly used Methods are
- GET -> to Get/Receive data
- POST -> to Create New Information.
- PUT -> to Update existing Information.
- DELETE -> to Delete data.
- Receive the Response & Parse it.
For every response you will receive Status Code which describes
- 1xx - Information Response Code
- 2xx - Success
- 3xx - Redirection
- 4xx - Client Errors
- 5xx - Server Errors
- Update UI.
Check this link for comparision between String/StringBuilder.
Check this link for performance comparision between Scanner/BufferedReader.
JSON - Java Script Object Notation.
It is a very common language-independent data format used for asynchronous browser–server communication, including as a replacement for XML
JSON Format is as below
Android provides 4 JSON Classes to extract information.
References: Udacity, Android Developer Document, Code Path, StackOverflow.