Now-a-days, Android is one of popular OS being used in the mobile. You can also find several android applications in the market. It has improved a lot over time. You can easily develop an application, having fascinating user-interface, using android. If you earn an average amount of money, you can easily get an android mobile having lots of features. This did not happen over night. Many developers contributed in it. They created several applications, libraries etc. Now-a-days, you can easily develop an android application with writing just a few lines of code. Thanks to developers and open source nature of android that made it possible. You can use this libraries, without spending a penny, in your project. A library may be for a specific task or for a group of task. You can also create a library for a task and contribute it to the developer society. Then, you will be one of those developers who made other developers life easier, tension free.
You would be wondering why do we use libraries to develop any application. Answer is very simple yet i will be covering the reasons point-wise.
a. Library is used to perform a specific task. That task may be – to download files from the server, to upload file to the server, to manage network calls, to cache server responses, to load image into views, to update a part of UI, to test a specific feature in the application etc.
b. If you are using library for a particular task, you do not need to write tons of code anymore to perform that task. You just need to configure the library and write a few lines of code. That’s it. You are done and you work will be done by library now. Isn’t it pretty feature?
c. You do not need to think about the test cases for the task if you are using library. Library will take care of most of the test cases. Only specific test cases, related to the application, might not be covered.
d. You application will have less code if you are using library. That means they are less prone to have error. They will also be easier to debug and manage now.
There are so many libraries in the market that can be used to perform these tasks. Some of them are very popular while some are not. In this tutorial, i will be covering some of the popular libraries available in the market now. You can use it in your project free of cost.
Android Volley library
Android Volley is an http library that is used to manage network calls in android. By default, network calls work asynchronously. That means, you do not need to write code for Async Task. By default, it handles everything you need to do while making network calls. It’s easier to use and works faster than most of the libraries. It handles image downloading and uploading, string request, JSON apis such as JSON Array request, JSON object request etc. If you are using Volley library then you do not need to write a ton of code to handle standard way of network calls using HttpURLConnection. The core of every network operation performed by Volley is RequestQueue. Whenever we need to send a network call, we create a RequestQueue and pass a request object in it. It manages the thread running the network operation, reading from and writing to the cache and finally parsing the response etc. You can also prioritise the request using this library i.e. you can decide the order in which requests will be performed. You can also customise for retry or back off a request. You can also handle transparent memory and disc caching. You can design the code to cancel a single request or multiple request depending upon the requirements.
If you want to use this library, please visit – Android Volley Tutorial With Example
Android AwesomeValidation Library
Validating any data before submitting it to the server has always been a tricky but easier task when you are using a proper library. If you are trying to achieve the same goal without using any library, it would be an extra headache to cover all the test cases. Specially when you have many fields in your page. So, using library is always a better choice. There are so many libraries in the market that can be used for validation. For example, Android Saripaar library for Validation, Android AwesomeValidation library for validation etc. AwesomeValidation is also easy to setup and use in the android application. AwesomeValidation library supports many validation rules. For example – String Type , Numeric , AlphaNumeric , IP Address , Web Url, Phone, Number, Year etc. If you want to use this library, please visit – Android AwesomeValidation Library Tutorial With Example
Android Saripaar Library
Generally, we look for a library that can be used for validation while submitting a form. Let’s take an example, we are creating a signup form that contains Name, Email, password, Confirm password, Phone number etc. Now, you would always prefer to validate the form in client side itself before submitting it to the server. You would like to check if the user has entered email or not, whether user has entered password and it matches to the password entered in confirm-password field etc. We can solve such scenario in 2 ways. They are as below –
a. Write code to validate every field by yourself. Think about the test cases that needs to tested and checked. Once all the test cases are passed, Submit the form to server.
b. Use some library to do your job. You just need to write few lines to configure the library. Then, you are done. This will check the test cases for you and if all test cases are passed, you can submit the form to the server.
What do you think? Which options are better?
Obviously, 2nd option is better because we do not need to bother about the test cases and other stuffs now. Just configure the library and you are done
Like AwesomeValidaiton library, you can also use saripaar library to achieve the above target. If you want to use saripaar library, please visit – Android Saripaar Library Tutorial With Example
Otto Event Bus Library
Imagine an app that has several activities and fragments in it. Also, we need to communicate among these components. By using interfaces, we can achieve it. But, it will be a headache to maintain and debug these codes. Moreover, components will be dependent on each other i.e. They will be tightly coupled. Also, It will be difficult to debug these codes. So, we need something that can be used to communicate between these components while keeping them independent from each other.
There are some popular android libraries that can be used for this purpose.
a. Guava event bus library.
b. Otto event bus library.
Other library (Otto event bus) is specifically designed for Android applications. Otto is an event bus designed to work as publisher-subscriber model. It is forked from Guava and adds unique functionality for android platform. You can communicate easily between different parts of application while keeping them independent from each other.
If you want to use Otto Event Bus Library, please visit – Otto Event Bus Library Tutorial With Example
Guava Event Bus Library
Imagine an app that has several activities and fragments in which each component communicates to a single or various components based on some actions. To manage and organise communications between components in such large application is very tedious work. By using EventBus library, such communications can be managed very easily.
EventBus is an open-source library for Android using the publisher/subscriber pattern for loose coupling. It enables central communication to decouple classes with just few lines of simplified code. You can easily pass messages from one class to another with few lines of code without any dependencies between classes. Thus, it speeds up application and make application easily debuggable. If you want to use Guava Event Bus library, please visit – Guava Event Bus Library Tutorial With Example
Glide is another popular android libraries for image downloading and caching, developed by bumptech. It is basically focused on smooth scrolling. Moreover, it is recommended by Google and google has used it in many official applications. It is a fast and efficient open source media management and image loading framework for Android that wraps media decoding, memory and disk caching and resource pooling into a simple and easy to use interface. It includes a flexible API that allows developers to plug in to almost any network stack. Glide’s primary focus is on making scrolling any kind of a list of images as smooth and fast as possible, but Glide is also effective for almost any case where you need to fetch, resize, and display a remote image.
a. Animated GIF decoding : you can load GIF animation into ImageView.
b. Display Video stills
c. Supports Thumbnail
e. Supports Animations
f. Supports OkHttp and Volley library
g. Placeholder can be added before loading the original image.
h. Any custom image can be shown if error occurs while loading the original image.
Note: Glide requires a minimum API level of 10. It can load huge images by downsampling them.
If you want to use Guava Event Bus library, please visit – Glide Library Tutorial With Example
Picasso library is a powerful android library, built by square, for image downloading and caching. It’s very simple to use and you need to write just a few lines of code to do the job. You can also show placeholder images while image is being downloaded. You can also show error image if error occurs while image is being downloaded. If you want to use this library, please visit – Android Picasso Library Tutorial With Example
Retrofit library is a type-safe HTTP client for Android and Java built by square. This library is easy to learn and has many features. You can send various requests like GET, POST, PUT, DELETE using this library. you can easily retrieve and upload JSON to a rest based web service using this library. Generally, we use Gson converter for JSON. But, we can add custom converters as well to process XML or other protocols. Retrofit uses OkHttp library for HTTP requests. If you want to use this library, please visit – Android Retrofit Library Tutorial With Example
We have just gone through various popular android libraries in this post. Some of them are use to manage network calls while some of them are used to download and show the image into different views. Depending on the requirements, we use different libraries in our android project.
If you have any suggestion about this post, please comment below. We are looking for someone who helps use to make our tutorial better. Also, If you want tutorials on any topic, you can mail us at email@example.com. We will try to cover the topic as soon as possible. Connect with us on Facebook, Google+, Twitter and Youtube for more updates.