How to Get Data From RESTful Webservice in Android Using JSON and OKHTTP

preview_player
Показать описание
How to Get Data From RESTful Webservice in Android Using JSON and OKHTTP

Subscribe To My Channel and Get More Great Tutorials

This tutorial describes how to receiving JSON data from REST service in android.

We used OKHTTP instead of built in Http client as it has a lot of benefits and lots of functionality over the built in Http client. This is an open source library from the giant company “Sqaure”.
OKHTTP is an open source project designed to be an efficient HTTP client. It supports the SPDY protocol. SPDY is the basis for HTTP 2.0 and allows multiple HTTP requests to be multiplexed over one socket connection.

There are alternative libraries to OKHTTP, such as Volley. Volley is an open source library form Google and officially supported. As they mentioned on their website Volley offers the following benefits:

• Automatic scheduling of network requests.
• Multiple concurrent network connections.
• Transparent disk and memory response caching with standard HTTP cache coherence.
• Support for request prioritization.
• Cancellation request API. You can cancel a single request, or you can set blocks or scopes of requests to cancel.
• Ease of customization, for example, for retry and backoff.
• Strong ordering that makes it easy to correctly populate your UI with data fetched asynchronously from the network.
• Debugging and tracing tools.

The code sample can be downloaded from following link:

►Android Developer Figurine◄

►New and Updated Android ASO Book◄

►Android Developer Books◄

►For Beginners◄

►For Experts◄

►Android Developer Gadgets◄

How to Get Data From RESTful Webservice in Android Using JSON and OKHTTP
Рекомендации по теме
Комментарии
Автор

Thank you for this video. Saved lot of time. Subscribed to your channel.

yogeshthite
Автор

Error, I used an api with one user and it ran normally, but when i run it inside the Studio it gives me null pointer exception !!!!

M.J.M.H
Автор

It's excellent! Thank you very much!!!

valeria-
Автор

i have one question if i need save this data in one variable how can do i ? sorry for my english i am learning and thanks for your answer

carloscaballeros
Автор

How do you store the JSON result? I have been trying to figure it for over a day.

asmcriminaL
Автор

Error: Invoke-customs are only supported starting with Android O (--min-api 26)
??

qm
welcome to shbcf.ru