![]() |
VOOZH | about |
Imagine you are traveling via Indian railways which is one of the biggest rail networks in the world. You want to get real-time updates for the train on which you are traveling so that you can plan accordingly. In this article, we will take a look at How to build a live train status checker application in Android. We will be using a method of web scraping to build this application to check live train status. A sample video is given below to get an idea about what we are going to do in this article.
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio. Note that select Kotlin as the programming language.
Below is the dependency for JSOUP which we will be using to scrap the data for our application. For adding this dependency navigate to the app > Gradle Scripts > build.gradle(app) and add the below dependency in the dependencies section.
implementation ("org.jsoup:jsoup:1.11.2")
implementation ("com.squareup.okhttp3:okhttp:4.9.1")
After adding this dependency sync your project and now move toward the AndroidManifest.xml part.
Navigate to the app > AndroidManifest.xml and add the below code to it.
Navigate to the app > res > layout > activity_main.xml and add the below code to that file. Below is the code for activity_main.xml file.
Navigate to app>java>your app's package name>MainActivity.kt file. Add below code to it. Comments are added in the code to get to know in detail.
Now run your application to see the output of the application.
Output: