Build an Android App to Check COVID-19 Vaccination Availability
- Android App Development Fundamentals for Beginners
- Guide to Install and Set up Android Studio
- Android | How to Create/Start a New Project in Android Studio?
- Android | Running your first Android app
- REST API (Introduction)
- Volley Library in Android
The government of India has started the biggest vaccination drive across India to give vaccination to people to fight against the COVID-19 virus. As there are so many vaccination centers in India for vaccination so to check the availability of different vaccination in different centers across India. We will be building a simple application for getting the details about vaccination centers in India.
What we will be building in this article?
We will be building a simple application in which we will be getting the data for the vaccination centers from the Pincode of that location. Below is the video in which we will get to see what we are going to build in this article. Note that we are going to implement this project using the Kotlin language.
Step 1: Opening a new project
- Open a new project just click of File option at the topmost corner in the left.
- Then click on new and open a new project with whatever name you want.
- Now we gonna work on Empty Activity with language as Kotlin. Leave all other options untouched.
- You can change the name of the project as per your choice
- By default, there will be two files activity_main.xml and MainActivity.java.
Or To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.
Step 2: Before going to the coding section first you have to do some pre-task
Go to the app > res > values > colors.xml section and set the colors for your app.
Step 3: Adding dependency for Volley in build.gradle file
Go to Gradle Scripts > build.gradle (Module: app) section and import the following dependencies and click the “sync Now” on the above pop-up. We have used the Volley library in this project.
// Volley library implementation 'com.android.volley:volley:1.1.1'
Step 4: Adding Internet Permissions in the AndroidManifest.xml file
Navigate to the app > AndroidManifest.xml file and add the below line of code in it.
Step 5: Working with the activity_main.xml file
Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for the activity_main.xml file.
Step 6: Creating a new Kotlin file for storing our data
We have to store the data in a modal class for that we will be creating a new Kotlin class file. For creating this file. Navigate to the app > java > your app’s package name > Right-click on it > New > Kotlin File/Class option and then choose Class and name your file as CenterRvModal and add the below code to it. Comments are added in the code to get to know in more detail.
Step 7: Creating a new layout file for our item of RecyclerView
Navigate to app >res > layout > Right-click on it > New > Layout file and name it as center_rv_item and add below code to it. Comments are added in the code to get to know in more detail. The below layout file can be used to display each item of our RecyclerView.
Note: Images used in the project are present in the drawable folder.
Step 8: Creating a new Kotlin file for our Adapter class
Now for setting data to each item of our Recycler View. We have to create a new adapter class for setting data to each item of our Recycler View. For creating a new Kotlin file, navigate to the app > java > your app’s package name > Right-click on it > New > Kotlin File/Class and name it as CenterRVAdapter and add the below code to it. Comments are added in the code to get to know in more detail.
Step 9: Working with MainActivity.kt file.
Navigate to the app > java > your app’s package name > MainActivity.kt file and add the below code to it. Comments are added in the code to get to know in more detail.
Now run your app and see the output of the app
Note: Our application will currently display the data available for the current date.