Android Volley Tutorial – User Registration and Login

Hey folks, heres another Android Volley Tutorial. If you remember one of remember one of the previous tutorial which was about creating a Login and Registration system for Android. You can check the post from below.

In the above mentioned tutorial we learnt how to send http request to our web services to make login and registration system. In this post we will do exactly the same thing but with Volley Library. Using volley library will simplify our task, and it is fast and it manages everything so you don’t need to worry. So lets start this Android Volley Tutorial.

Android Volley Tutorial – Video

  • You can also follow this video tutorial series to learn the same.

Android Volley Tutorial – User Registration and Login

Creating Web Services

  • So first we need the Web Services for User Registration and Login. We also need MySQL Database. Now you can use other technologies for your server side as well. It is obvious not mandatory to use PHP and MySQL only. But here I am using PHP and MySQL.
  • And the best thing here is I will not be doing this thing in this post hahaha 😛 (LOL). Because in the last post which you can see from the below link, we already built web services for the User Registration and Login. And here I will be using the same thing. So go through the link given below first then move further in this post.

Learn Creating Web Services Here

Android Login and Registration

Creating a new Project

  • As always we need a new Android Studio project. So create a project named SimplifiedCoding (You can actually name it whatever you want) with an EmptyActivity.
  • Once your project is loaded create two more activities here named LoginActivity and ProfileActivity.
  • Now lets design the screens first.

User Interface Design

Registration Screen
  • So come inside activity_main.xml and write the following xml code.

  • You will see the following design with the above given xml code.

android registration

Login Screen
  • For the login screen come inside activity_login.xml and write the following xml code.

  • The above code will generate the output as shown below.

user login screen

Profile Screen
  • Lastly we will design the profile screen using the following xml code.

  • You will see the profile screen looking as shown below.

profile screen

Creating Helper Classes

  • It is very important that we organize our code well so that it can be reused. That is why here we are creating different classes for different task. Though we are doing exactly the same we did in the last post.
User Model Class
  • First we will create a class for our User. So create a class named and write the following code inside. The code contains nothing but only the user attributes with a constructor and getters. You can easily do this by right click -> generate -> constructor/ getters.

SharedPrefManager Class
  • In android side to maintain a user login session, here we are using SharedPreferenes. Inside SharedPreferences we will store the data of currently logged in user. So that we can use it in our application. So to handle all the sharedpreferences task at one place we are having this class named

Web Service URLs
  • Create a new class named to put all the Web Service URLs at one place. So here I am using a class named

  • Now we have all the helper classes.

Adding Volley Library

  • As in this project we need to use Volley for the network operation, and for this we need to add Volley to this project.
  • For this come inside app level build.gradle file and inside dependencies block add volley.

  • After adding this you need to sync your project.

Adding Internet Permission

  • As networking operations requires internet permission so inside AndroidManifest.xml define the internet permission for the application.

Using Singleton Pattern for Volley

  • As any app requires many network operations. So in this case it is always a good idea to use a single instance of Volley RequestQueue. For this we will use a Singleton Pattern for handling all the request queues.
  • So create a new class named and write the following code.

User Registration

  • Now lets perform the user registration inside The code is very simple and it is actually explaining itself. But if you think you have some confusions at some lines, feel free to comment and I will try to help you.

  • If you are facing some problem understanding the codes, you can check the video tutorials given at the starting of this post.

User Profile

  • Come inside and write the following code. Here we are only displaying the User data and we have a button that will let the user logout from the app.

  • Now lastly we will code the LoginActivity.

User Login

  • Come inside and write the following code. It is almost same as the User Registration Activity (

  • Now you can test the application.
android volley tutorial
Android Volley Tutorial – User Registration and Login
  • Bingo! It is working absolutely fine.

Source Code Download

  • If you are having some troubles creating the project then don’t worry I am giving you the complete source code here. You can download it from below.

So thats all for this Android Volley Tutorial friends. If you found this helpful then please SHARE it. If having any feedbacks, suggestions or queries, please comment it.

30 thoughts on “Android Volley Tutorial – User Registration and Login”

  1. Nice peace of code, easy to understand. I used to play a lot with the Async way to send and get data, and was looking for a basic Volley example. Yours seems to be the only one with only the basic Really cool to start with. Thanks a lot.

  2. i need your help

    now i am doing login and registration using volley library i successfully post the data at the time of registration .But don’t how to call response from server at the time of login

  3. Your code is avesome belal but what if i had changed my password in database and now its seems your code will check data stored in sharedpref it will not check automatically from the existing database

    in short what all i want is can you help me to check user email and password each time when i open application so can you help me out i am stuck here

    • This is a simple example of authentication.. Really basic stuff.. We don’t use this in real world production apps. For production apps you have to go with some token based authentication.

      • can you give me some reference,documentation or you had created an article for token based authentication because your examples are very easy to learn

  4. hey dude ! i need to post longitude and latitude and i have to return json_encoded(many rows) and they i have to show it in recyclerview how can i do that?

  5. Sir,why am I not being able to fetch data from the database in the login form which is not directing me towards the profile activity?

  6. hi,

    Thank you for ur tutorial. failed to connect to / (port 443) from / (port 49247) after 300000ms: isConnected failed: ETIMEDOUT (Connection timed out)

    I got the above error while trying to register. I use my mobile phone instead of emulator. How can I rectify that??

  7. hi i got error in your code at register “org.json.JSONException: Value [] of type org.json.JSONArray cannot be converted to JSONObject”

    please help me for this solution.

  8. Fine way of telling, and good post to take data about my presentation subject, which i am going to deliver in institution of higher education.


Leave a Comment