Android SDK allows your app to connect to the internet as well as perform network operations in multiple ways. This tutorial explains different ways in which you can connect to a network.
Android SDK used to come with 2 HTTP client packages
However as of Android 6.0 , the android team has removed the Apache HTTP client, and advices to use the HttpURLConnection class instead. So we would be talking only about HttpURLConnection in this tutorial.
HttpURLConnection API includes Java’s HttpURLConnection and URL classes. It uses low level code that can do anything and supports all basic HTTP features.It supports resource compression and response caching that can significantly reduce network usage. This API , however requires more code than the higher-level libraries. Most important reason to use this library is that it is in active development by the Android Dev team.
Apart from HttpURLConnection API there are plenty of Open Source Networking Libraries which can be used to connect to internet in an Android app. Most popular ones are
|Android Networking Libraries|
|okHttp||OkHttp is an effecint HTTP client that provides support for Connection pooling and|
Response caching. You can use OkHttp without rewriting your network code since the okhttp-urlconnection module implements the familiar java.net.HttpURLConnection API
|Volley||Volley is an HTTP library that makes networking for Android apps easier and faster.|
It allows for Automatic Scheduling of Network requests, multiple concurrent connectionsand and response caching.It also supports request prioritization and cancellation.
|Retrofit||Retrofit is a type-safe REST client for Android and Java. This uses annotation to describe HTTP server calls.Retrofit is very efficient for managing REST API calls in android application programming.|
|Picasso||Picasso is a powerful image downloading and caching library for Android|
|Android Universal Image Loader||Another good Image Loader, UIL aims to provide a powerful, flexible and highly customizable library for image loading, caching and displaying the content in a lot of configuration options.|
We will be covering some of these libraries in detail in future articles.