0% found this document useful (0 votes)
23 views78 pages

Industrial Training Final Report

The document is an internship report on 'Android Application Development' submitted by students from SVERI's College of Engineering, detailing their training at TechnoWings Solutions Pvt. Ltd. It includes acknowledgments, an abstract about the company, a weekly overview of internship activities, and outlines the methodologies and processes used in software development. The report emphasizes the importance of internships for gaining real-world experience and developing technical skills in the field of information technology.

Uploaded by

thoratgauri97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views78 pages

Industrial Training Final Report

The document is an internship report on 'Android Application Development' submitted by students from SVERI's College of Engineering, detailing their training at TechnoWings Solutions Pvt. Ltd. It includes acknowledgments, an abstract about the company, a weekly overview of internship activities, and outlines the methodologies and processes used in software development. The report emphasizes the importance of internships for gaining real-world experience and developing technical skills in the field of information technology.

Uploaded by

thoratgauri97
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 78

INTERNSHIP REPORT ON

“Android Application Development ”

Submitted in partial fulfilment of the requirements of the award of


degree of
DIPLOMA ENGINEERING
In
INFORMATION TECHNOLOGY
BY:-

Pranjal Kiran Kokare


Aditi Manojkumar Jawanjal
Gauri Santosh Thorat
Sharayu Sachin Bajare

STUDENT NAME
UNDER THE GUIDANCE:

Mr.Sumit Umbare
(Technowings Solutions Pvt. Ltd.,Solapur )
SVERI’S
COLLEGE OF ENGINEERING (POLY).
PANDHARPUR 2024-25

CERTIFICATE
The project report entitled

“Android Application Development”

Submitted by

Roll No Name of Student Enrollment No.


16 Pranjal Kiran Kokare 2210740518
22 Adiit Manojkumar Jawanjal 2210740524
35 Gauri Santosh Thorat 22107405
58 Sharayu Sachin Bajare

Is approved for the Diploma of Engineering in Information Techonology from


SVERI’S College of Engineering (Polytechnic), Pandharpur.

Name of Guide Name of Mentor

Technowings Solutions Pvt.,Ltd. Department of Information Techonology

Solpur-413001 SVERI’s COE(Poly),Pandharpur

. (Mr.Sumit Umbare) (Mrs.R.K.Malgonde)

Name of H.O.D Name of Principle

Department of Computer Engineering SVERI’S COE (Poly), Pandharpur

. SVERI’S COE (Poly), Pandharpur.

(Prof.G.S.misal) (Prof. Dr. N. D. Misal)

Date:

Place: Pandharpur Examiner Principal


Declaration by candidate

I hereby declare that the Industrial Training based on “Android Application Development”
completed in Technowings Solutions Pvt. Ltd.,Solapur, Solapur. Submitted to Maharashtra State
Board of Technical Education (MSBTE),for Computer Engineering in Shri Vithal Education and
Research Institute College of engineering polytechnic Pandharpur under the guidance of
Mr.Bandenawaz Bagwan.

I further declare that it has not been submitted to any other university or institution for the award
of diploma. I also confirm that all the literature which I have borrowed from other source and
incorporated in seminar report is duly acknowledge. If any literature is not duly acknowledge
and found incorporated in this report, it entirely my responsibility.

Date:
Place: [student name] Pranjal Kiran Kokare
Aditi Manojkumar Jawanjal
Gauri Santosh Thorat
Sharayu Santosh Bajare
Certificate by Guide

This is to certify that Ms. Pranjal Kiran Kokare has completed the Industrial Trainning under my
guidance and supervision and that, I have verified the work for its originality in documentation,
problem statement, implementation and results presented in the Industrial Trainning . Any
reproduction of other necessary work is with the prior permission and has given due ownership and
included in the references.

Place:
Date: Signature of Guide
(Mr.Sumit Umbare)
Contents:

Acknowledgement………………… I

Abstract…………………………… II

List of Figures…………………….. III

List of Tables………………………. IV

List of Abbreviations………………. V
ACKNOWLEDGEMENT

We take this opportunity to thank all the individuals for their guidance, help and timely support
which made us to complete the project in stipulated time. It gives us great pleasure and immense
satisfaction to present this project report on “Android Application Development” which is the result
of unwavering support, guidance and focused direction of our guide Mr.Sumit Umabare whom I
express our deep sense of gratitude and humble thanks, for his valuable guidance throughout the
project work.
The success of this project has throughout depended upon an exact blend of hard work and
unending co-operation and guidance, extended to us by the superiors at our college.
Furthermore, we are indebted to Prof.G.S.Misal, H.O.D, I n f o r m a t i o n t e c h n o l o g y and
Dr.N.D.Misal Principal whose constant encouragement and motivation inspired us to do our best.
Lastly, we offer my regard for all those, in particular our parents, who supported us in every respect
during this project

Student Name
Pranjal Kiran Kokare
Aditi Manojkumar Jawanjal
Gauri Santosh Thorat
Sharayu Sachin Bajare
ABSTRACT

The Company :
TechnoWings is a complete IT Solutions & IT enabled Services Company for offering services like
Software Development & Consulting, IT Infrastructure Services, IT Training & Services, Manpower
recruitment & Outsourcing Consultancy Services are some of the major working area of our company.
TechnoWings has evolved as an organization by continuously adding value to the businesses of our clients
by innovative use of Training & Technology. Today, our operations have taken a flying shape to serve the
industry verticals such as Educational Industry (Institutions, Schools & Colleges), Retail Industry,
Manufacturing Industry, Healthcare Industry, and Financial Services & Government Sectors with a business
solution.

• Programmers and opportunities:


INPLANT TRAINING IN TechnoWings - WHY ITS IMPORTANT?

The term, Inplant Training in TechnoWings -> Inplant training is really important to gain knowledge of
real time technologies and to get job. TechnoWings Inplant Training focus towards latest job oriented
technologies and improve interview related aspects. The breadth of Engineering may be best understood
in terms of the general areas of software systems, hardware, theory and applications. Now a days it has
been significant improvement in the usability and efficiency of computing technology.

• Methodology:
This project is to provide classifieds information. The GUI will provide different kinds of
facilities to the user related Online Examination System. Each user will be given 10 question . After
Completing the Quize user will get output of or Result in the percentage on correct answers.

• Benefits to the company / institution through your report:


The Institute combines pioneering research with top class education. An innovative curriculum
allows the student flexibility in selecting courses and projects. Students, even at the undergraduate level,
get to participate in on-going research and technology development - an opportunity unprecedented in
India.
WEEKLY OVERVIEW OF INTERNSHIP ACTIVITIES

E
DATE DAY NAME OF THE TOPIC/MODULE
E

COMPLETED
W

14/06/23
Wednesday Basic Of Python ,Python Introduction

15/06/23 Thursday
Installation Of Python

16/06/23 Friday
Identifiers and Keywords in Python

17/06/23 Saturday
Indention ,Comments

Monday
19/06/23 Variables,Python Environment setup

20/06/23 Tuesday , Operators in Python


K

E
DATE DAY NAME OF THETOPIC/MODULE
E

COMPLETED
W

21/06/23 Wednesday
Datatypes In Python,Syntax

22/06//23 Thursday
Conditinal Statements,And Loops In Python

23/06/23 Friday Practical Assignments.

24/06/23 Saturday
Control Flow Statements In Python

26/06/23 Monday
Numbers And Methods of Math

27/06/23 Tuesday
Strings, List and Tupels
DATE DAY NAME OF THETOPIC/MODULE
COMPLETED

28/06/23 Wednesday Python Built in Function, User defined


function:calling ,arguments & parameter
passing

28/06/23 Thursday Global and local variables


modules :Importing module

30/06/23 Friday Python Packages ,Namespace, Creating


classes and
objects

01/07/23 Saturday Data hiding and data abstraction,


Inheritance ,types of
inheritance

03/07/23 Monday Exception handling introduction, Exception


handling
using try : and except:

04/07/23 Tuesday Files Input/Output in Python , Files and


their Methods
K

E DATE DAY NAME OF THE TOPIC/MODULE


E

COMPLETED
W

05/07/ Final Lecture and Project Presentation


23 Wednes
day

06/07/ Introduction to android.

23 Thursda
y

07/07/ Fr Installing Android Studio and its Information

23 id
ay

08/07/ Creating a Sample Project

23 Saturda
y

10/07/ Adding Labels in And Creating xml Files

23 Monda
y
K

E
DATE DAY NAME OF THE
TOPIC/MODULE
E

COMPLETED
W

12/07/23 Wednesday Control flow directory structure,Layouts


in Android

Thursday Giving Permissions Like Camera access


13/07/23 StorageAccess

Friday Simple Picture Taking Application.


14/07/23

Simple Message Sending Application.


15/07/23 Saturday

Monday Connecting Mysql database To the Android.


17/07/23

Tuesday Inserting Data to the Database.


18/07/23

E
DATE DAY NAME OF THETOPIC/MODULE COMPLETED
E

19/07/23 Wednesday Updating and Deleting the data in database.

20/07/23 Thursday How to store data in database

21/07/23 Friday Store data using firebase

22/07/23 Saturday Validating form data using database

24/07/23 Monday Final lecture. How to create github Account and


19/07/23 Wednesday push the code on github.
Updating and Deleting the data in database.
INDEX

1. Structure Of Industry

2. Introduction to Organization

Types,Services

Number Of Employees

3. Eqipments Used

4. Process Of Development

Planning and Control Methods

5. Testing

6. Safety Products

7. Maintainance

8. Project In Training

9. Screenshot

10.Conclusion
Learning Objectives/Internship Objectives

▪ Internships are generally thought of to be reserved for college students looking to


gainexperience in a particular field. However, a wide array of people can benefit from
Training Internships in order to receive real world experience and develop their skills.
▪ An objective for this position should emphasize the skills you already possess in the
area andyour interest in learning more
▪ Internships are utilized in a number of different career fields, including
architecture,engineering, healthcare, economics, advertising and many more.
▪ Some internship is used to allow individuals to perform scientific research while others
are specifically designed to allow people to gain first-hand experience working.
▪ Utilizing internships is a great way to build your resume and develop skills that can be
emphasized in yourresume for future jobs. When you are applying for a Training
Internship, make sure to highlight any special skills or talents that can make you stand
apart from the rest of the applicants so that you have an improved chance of landing the
position.
1. INTRODUCTION

TechnoWings is a complete IT Solutions & IT enabled Services Company for offering services like Software
Development & Consulting, IT Infrastructure Services, IT Training & Services, Manpower recruitment &
Outsourcing Consultancy Services are some of the major working area of our company. TechnoWings has
evolved as an organization by continuously adding value to the businesses of our clients by innovative use of
Training & Technology. Today, our operations have taken a flying shape to serve the industry verticals such
as Educational Industry (Institutions, Schools & Colleges), Retail Industry, Manufacturing Industry,
Healthcare Industry, and Financial Services & Government Sectors with a business solution.

Our Vision
Our Vision is to help the Customers with the latest Technologies & Training so become the preferred choice
to be the business Partner

Our Mission
Our Mission is to “Help the Customers to Build the Business”.
Chapter 2

Introduction To Organization

TechnoWings is not an entity, it’s a family that represents togetherness for over two decades of a
successful journey. For TechnoWings, the definition of success is to transcend innovative ideas of people to
reality with the help of our tech expertise, this is what we, as a Team, want to be remembered for!
Our vision has led TechnoWings to become a top IT company in Worldwide for delivering various industry-
led mobility solutions. The goal is to empower clients and businesses by creating new possibilities leveraging
the technologies of today and tomorrow with the utmost quality, satisfaction, and transparency.

Our enthusiasm has led us to become a top IT company in Worldwide for delivering various industry-
led mobility solutions in web and mobile application development domains leveraging futuristic technologies
like Internet of Things (IOT), AI-ML, AR-VR, Voice assistants and Voice Skills, DevOps & Cloud
computing, etc.We feel empowered with our certified tech experts and our R&D team who have always
challenged themselves to help global clientele with a plethora of IT services and solutions. Engagement with
our team guarantees our clients to save huge money on project development with faster delivery.
Chapter 3

Equipment’s Used

• Traditional Methodologies

o The Waterfall Model

o The Critical Path Method

o The Critical Chain Method

• Agile Methodologies

o Agile Project Management

o The Scrum Framework

o Kanban

o Extreme Programming

o Adaptive Project Framework

• Change Management Methodologies

o Event Chain Methodology

o Extreme Project Management

• Other Methodologies

o Rational Unified Process

o Program Evaluation & Review Technique

o The PMBOK Method

• Project Management Tools


.Recruitment life cycle diagram:
Chapter 4

Process Of Development

The Waterfall Model


The Waterfall approach suggests a sequential approach to managing projects. After stakeholders and
customers agree on and document project requirements, it’s executed in a step-by-step manner until it’s
finished. After that, the customer reviews the project to make sure that it meets the requirements. Some
projects require a post-production maintenance stage, e.g., software projects, where the customer reports bugs
and requests new features to ensure lasting project performance and success.

The most commonly preferred tool for the Waterfall model is the Gantt chart which visualizes subtasks,
dependencies and project phases as it goes through the project life cycle.

Best for: short and simple projects with clear guidelines that require a strict work structure to ensure project
success.

• Requirement Gathering and analysis − All possible requirements of the system to be developed are
captured in this phase and documented in a requirement specification document.
• System Design − The requirement specifications from first phase are studied in this phase and the
system design is prepared. This system design helps in specifying hardware and system requirements
and helps in defining the overall system architecture.
• Implementation − With inputs from the system design, the system is first developed in small programs
called units, which are integrated in the next phase. Each unit is developed and tested for its
functionality, which is referred to as Unit Testing.
• Integration and Testing − All the units developed in the implementation phase are integrated into a
system after testing of each unit. Post integration the entire system is tested for any faults and failures.

• Deployment of system − Once the functional and non-functional testing is done; the product is
deployed in the customer environment or released into the market.
• Maintenance − There are some issues which come up in the client environment. To fix those issues,
patches are released. Also to enhance the product some better versions are released. Maintenance is
done to deliver these changes in the customer environment.
Chapter 5

Testing

There are different methods that can be used for software testing. This chapter briefly describes the methods
available.

Black-Box Testing
The technique of testing without having any knowledge of the interior workings of the application is called
black-box testing. The tester is oblivious to the system architecture and does not have access to the source
code. Typically, while performing a black-box test, a tester will interact with the system's user interface by
providing inputs and examining outputs without knowing how and where the inputs are worked upon.
The following table lists the advantages and disadvantages of black-box testing.

Advantages Disadvantages

Well suited and efficient for large code segments. Limited coverage, since only a selected number
of test scenarios is actually performed.

Code access is not required. Inefficient testing, due to the fact that the tester
only has limited knowledge about an
application.

Clearly separates user's perspective from the Blind coverage, since the tester cannot target
developer's perspective through visibly defined roles. specific code segments or errorprone areas.

Large numbers of moderately skilled testers can test the The test cases are difficult to design.
application with no knowledge of implementation,
programming language, or operating systems.

White-Box Testing
White-box testing is the detailed investigation of internal logic and structure of the code. White-box testing is
also called glass testing or open-box testing. In order to perform white-box testing on an application, a tester
needs to know the internal workings of the code.
The tester needs to have a look inside the source code and find out which unit/chunk of the code is behaving
inappropriately.
The following table lists the advantages and disadvantages of white-box testing.

Advantages Disadvantages

As the tester has knowledge of the source code, it Due to the fact that a skilled tester is needed to
becomes very easy to find out which type of data can perform white-box testing, the costs are
help in testing the application effectively. increased.

It helps in optimizing the code. Sometimes it is impossible to look into every


nook and corner to find out hidden errors that
may create problems, as many paths will go
untested.

Extra lines of code can be removed which can bring in It is difficult to maintain white-box testing, as it
hidden defects. requires specialized tools like code analyzers
and debugging tools.

Due to the tester's knowledge about the code,


maximum coverage is attained during test scenario
writing.

Black-Box Testing White-Box Testing

The internal workings of an application need not be Tester has full knowledge of the internal
known. workings of the application.

Also known as closed-box testing, data-driven testing, Also known as clear-box testing, structural
or functional testing. testing, or code-based testing.

Performed by end-users and also by testers and Normally done by testers and developers.
developers.

Testing is based on external expectations - Internal Internal workings are fully known and the
behavior of the application is unknown. tester can design test data accordingly.

It is exhaustive and the least time-consuming. The most exhaustive and time-consuming type
of testing.

Not suited for algorithm testing. Suited for algorithm testing.

This can only be done by trial-and-error method. Data domains and internal boundaries can be
better tested.
Chapter 6

Safety Products

SAFETY CASE ARCHITECTURES AND NEGATIVE REQUIREMENTS

The previous section describes how software to software techniques can be used in conjunction with software
to system techniques in order to identify unwanted software behaviour. However, it is sometimes the case that
the software is not amenable to sufficiently rigorous examination that would allow us to claim that all
unwanted behaviours have been identified [7]. Safety arguments, therefore, have typically considered the
absence of specified behaviours only. For example, software FMEA [10] can demonstrate that certain defined
software failures do not contribute unacceptably to system safety. However, such safety arguments do not
always justify the omission of other software failures from the analysis, and as a result can sometimes be
judged insufficiently complete. The concept of well-behavedness [3] enables us to address this incompleteness
problem. Well-behavedness of software in a SoS refers to the general integrity [5] of that software’s
behaviours: in essence, well-behavedness is a requirement that certain categories of undesirable behaviour
should not occur. Examples of well-behavedness requirements include those relating to non-interference
between components, the absence of unintended communications between components, absence of data
corruption across communication paths, and absence of resource starvation. A single well-behavedness
requirement can therefore be seen as an abstraction away from specific undesirable behaviours to describe an
entire class of unwanted behaviour. For example, instead of arguing about the absence of all possible
behaviours resulting from corruption of some specified communication data between two specified
components, we can simply argue the well-behavedness property that the components and methods
responsible for communication within a SoS do not corrupt (any) data.
Chapter 7

Software Maintainance

What is Software Maintenance?

Software maintenance is the process of changing, modifying, and updating software to keep up with
customer needs. Software maintenance is done after the product has launched for several reasons including
improving the software overall, correcting issues or bugs, to boost performance, and more.
Software maintenance is a natural part of SDLC (software development life cycle). Software developers don’t
have the luxury of launching a product and letting it run, they constantly need to be on the lookout to both
correct and improve their software to remain competitive and relevant.

Using the right software maintenance techniques and strategies is a critical part of keeping any software
running for a long period of time and keeping customers and users happy.

Why is software maintenance important?

Creating a new piece of software and launching it into the world is an exciting step for any company. A lot
goes into creating your software and its launch including the actual building and coding, licensing models,
marketing, and more. However, any great piece of software must be able to adapt to the times.

This means monitoring and maintaining properly. As technology is changing at the speed of light, software
must keep up with the market changes and demands.

What are the 4 types of software maintenance?

The four different types of software maintenance are each performed for different reasons and purposes. A
given piece of software may have to undergo one, two, or all types of maintenance throughout its lifespan.

The four types are:


Corrective Software Maintenance
Preventative Software Maintenance
Perfective Software Maintenance
Adaptive Software Maintenance
Corrective Software Maintenance

Corrective software maintenance is the typical, classic form of maintenance (for software and anything else
for that matter). Corrective software maintenance is necessary when something goes wrong in a piece of
software including faults and errors. These can have a widespread impact on the functionality of the software
in general and therefore must be addressed as quickly as possible.

Many times, software vendors can address issues that require corrective maintenance due to bug reports that
users send in. If a company can recognize and take care of faults before users discover them, this is an added
advantage that will make your company seem more reputable and reliable (no one likes an error message after
all).
Preventative Software Maintenance

Preventative software maintenance is looking into the future so that your software can keep working as desired
for as long as possible.

This includes making necessary changes, upgrades, adaptations and more. Preventative software maintenance
may address small issues which at the given time may lack significance but may turn into larger problems in
the future. These are called latent faults which need to be detected and corrected to make sure that they won’t
turn into effective faults.

Perfective Software Maintenance

As with any product on the market, once the software is released to the public, new issues and ideas come to
the surface. Users may see the need for new features or requirements that they would like to see in the software
to make it the best tool available for their needs. This is when perfective software maintenance comes into
play.

Perfective software maintenance aims to adjust software by adding new features as necessary and removing
features that are irrelevant or not effective in the given software. This process keeps software relevant as the
market, and user needs, change.

Adaptive Software Maintenance

Adaptive software maintenance has to do with the changing technologies as well as policies and rules
regarding your software. These include operating system changes, cloud storage, hardware, etc. When these
changes are performed, your software must adapt in order to properly meet new requirements and continue to
run well.

1.1 MODULES:
1. Group Information
2. Qustion Pages
3. Submitting Test
4. Result
Chapter 8

Project In Trainning
Frontend

1.We will create data.Students for storing the data.

The data for the Students is defined in data.Students with student data which are name/
Email-address , password and Confirm password. We have defined sample data for the
student as shown below :
In order to create the Tution Application, we will need some data. We can define this data
in a Students file, called data.Student, with student data which are name/Email-
address,password and Confirm password.

Android Code

Activity_Main.xml
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".start">

<ImageView
android:layout_width="300dp"
android:layout_height="300dp"
android:id="@+id/i1"

android:layout_x="55dp"
android:layout_y="185dp"
android:src="@drawable/map" />

<TextView
android:id="@+id/t1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="93dp"
android:layout_y="495dp"
android:text="Tracking College Bus"
android:textColor="@color/black"
android:textSize="25sp"
android:textStyle="bold" />

<TextView
android:id="@+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="56dp"
android:layout_y="536dp"
android:text="Track your college bus everywhere \n in every minute"
android:textColor="@color/black"
android:textSize="20sp"
android:textStyle="normal" />

<Button
android:id="@+id/b1"
android:layout_width="match_parent"
android:layout_height="wrap_content"

android:layout_x="-10dp"
android:layout_y="627dp"
android:text="Start"
android:onClick="start1"/>

</AbsoluteLayout>

//java code of 1st page


import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class login extends AppCompatActivity {


RadioButton stu;
RadioGroup rg;
RadioButton ad;

Button b;

@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_login);
b = findViewById(R.id.sub);

rg = findViewById(R.id.rg);

stu = findViewById(R.id.stu);
ad = findViewById(R.id.ad);

public void perform(View view) {


if (ad == findViewById(rg.getCheckedRadioButtonId())) {
Intent i = new Intent(login.this, DASHBOARD.class);
startActivity(i);
}

if (stu == findViewById(rg.getCheckedRadioButtonId())) {
Intent i = new Intent(login.this, StudentDashboard.class);
startActivity(i);
}

}
}
//Xml file of login page

<?xml version="1.0" encoding="utf-8"?>


<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".login"
android:background="@drawable/image1"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="57dp"
android:layout_x="75dp"
android:layout_y="64dp"
android:textStyle="bold"
android:textColor="@color/white"
android:text="Select Your Role"
android:textSize="40dp"
/>

<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="230dp"
android:id="@+id/rg">

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="200dp"
android:layout_y="300dp"
android:text="Student"
android:textSize="40dp"
android:textStyle="bold"
android:textColor="@color/white"
android:id="@+id/stu" />

<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="28dp"
android:layout_y="345dp"
android:text="Admin"
android:textSize="40dp"
android:textStyle="bold"
android:textColor="@color/white"
android:id="@+id/ad"/>

</RadioGroup>

<Button
android:id="@+id/sub"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_x="5dp"
android:layout_y="510dp"
android:onClick="perform"
android:text="Submit" />

</AbsoluteLayout>
Java code of login page

package com.example.collegebustracking;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class login extends AppCompatActivity {


RadioButton stu;
RadioGroup rg;
RadioButton ad;

Button b;

@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_login);
b = findViewById(R.id.sub);

rg = findViewById(R.id.rg);

stu = findViewById(R.id.stu);
ad = findViewById(R.id.ad);

public void perform(View view) {


if (ad == findViewById(rg.getCheckedRadioButtonId())) {
Intent i = new Intent(login.this, DASHBOARD.class);
startActivity(i);
}

if (stu == findViewById(rg.getCheckedRadioButtonId())) {
Intent i = new Intent(login.this, StudentDashboard.class);
startActivity(i);
}

}
}
//Xml file of student dashboard

<?xml version="1.0" encoding="utf-8"?>


<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/image1"
tools:context=".Student">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="151dp"
android:layout_y="30dp"
android:text="Student"
android:textSize="30sp"
android:textStyle="bold"
android:textColor="@color/white"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="4dp"
android:layout_y="155dp"
android:text="Name"
android:textSize="26sp"
android:textColor="@color/white"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="4dp"
android:layout_y="273dp"
android:text="Select Your Route"
android:textColor="@color/white"
android:textSize="26sp" />

<EditText
android:id="@+id/u_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="3dp"
android:layout_y="200dp"
android:textColorHint="@color/white"
android:hint="Enter Your Full Name" />

<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="20dp"
android:layout_y="350dp"
android:id="@+id/rg">

<RadioButton
android:id="@+id/sangola"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="0dp"
android:layout_y="145dp"
android:text="sangola"
android:textColor="@color/white"
android:textSize="26dp" />

<RadioButton
android:id="@+id/mangalvedha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="6dp"
android:layout_y="320dp"
android:text="Mangalvedha"
android:textSize="26dp"
android:textColor="@color/white"/>

<RadioButton
android:id="@+id/pandharpur"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="9dp"
android:layout_y="377dp"
android:text="Pandharpur"
android:textSize="26dp"
android:textColor="@color/white"/>

<RadioButton
android:id="@+id/gopalpur"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="13dp"
android:layout_y="426dp"
android:textSize="26dp"
android:textColor="@color/white"
android:text="Gopalpur" />

</RadioGroup>

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="2dp"
android:layout_y="594dp"
android:text="SUBMIT" />
</AbsoluteLayout>

Java code of student dashboard

package com.example.collegebustracking;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class StudentDashboard extends AppCompatActivity {

private EditText userName;


private RadioGroup radioGroup;
private RadioButton sangola, mangalvedha, pandharpur, gopalpur;
@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_student_dashboard); // Make sure your XML
layout file is named activity_student.xml

userName = findViewById(R.id.u_name);
radioGroup = findViewById(R.id.rg);
sangola = findViewById(R.id.sangola);
mangalvedha = findViewById(R.id.mangalvedha);
pandharpur = findViewById(R.id.pandharpur);
gopalpur = findViewById(R.id.gopalpur);

radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton selectedRadioButton = findViewById(checkedId);
// Handle the selection
}
});
}

// You can create a method to get the selected route if needed


private String getSelectedRoute() {
int selectedId = radioGroup.getCheckedRadioButtonId();
if (selectedId != -1) {
RadioButton selectedRadioButton = findViewById(selectedId);
return selectedRadioButton.getText().toString();
} else {
return null;
}
}

// You can also create a method to get the entered name if needed
private String getEnteredName() {
return userName.getText().toString();
}
}

xml code of admin dashboard

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/image1"
tools:context=".DASHBOARD">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="College Bus Tracking"
android:textColor="#FFF"
android:textSize="30dp"
android:layout_margin="17dp"
android:textStyle="bold"
android:id="@+id/t" />
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/t"
android:layout_margin="20dp"
android:columnCount="2"
android:rowCount="2">

<androidx.cardview.widget.CardView
android:id="@+id/a1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_row="0"
android:layout_column="0"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_gravity="fill"
app:cardBackgroundColor="#0000FF"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">

<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/student"
android:id="@+id/i1"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Student"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:textSize="18dp"
android:id="@+id/t1"
android:onClick="addStudent"/>
</LinearLayout>
</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:id="@+id/a2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_row="0"
android:layout_column="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_gravity="fill"
app:cardBackgroundColor="#0000FF"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true"
>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">

<ImageView
android:layout_width="100dp"
android:layout_height="100dp"

android:src="@drawable/driver"
android:id="@+id/i2"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Driver"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:textSize="21dp"
android:id="@+id/t2"
android:onClick="addDriver"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="@+id/a3"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_row="1"
android:layout_column="0"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_gravity="fill"
app:cardBackgroundColor="#0000FF"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">

<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/nwebus"
android:id="@+id/i3"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add Bus"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:textSize="21dp"
android:id="@+id/t3"
android:onClick="addBus"/>

</LinearLayout>
</androidx.cardview.widget.CardView>

<androidx.cardview.widget.CardView
android:id="@+id/a4"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_row="1"

android:layout_column="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_gravity="fill"
app:cardBackgroundColor="#0000FF"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">

<ImageView

android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/driver"
android:id="@+id/i4"/>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="View History"
android:textAlignment="center"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:textSize="17dp"
android:id="@+id/t4"/>

</LinearLayout>
</androidx.cardview.widget.CardView>

</GridLayout>

</RelativeLayout>

Java code of admin dashoard

package com.example.collegebustracking;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class DASHBOARD extends AppCompatActivity {

TextView t1,t2,t3,t4;

ImageView i1,i2,i3,i4;

@SuppressLint("MissingInflatedId")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_dashboard);
t1=findViewById(R.id.t1);
t2=findViewById(R.id.t2);
t3=findViewById(R.id.t3);
t4=findViewById(R.id.t4);
i1=findViewById(R.id.i1);
i2=findViewById(R.id.i2);
i3=findViewById(R.id.i3);
i4=findViewById(R.id.i4);
}
public void addStudent(View view)
{
Intent i=new Intent(DASHBOARD.this,StudentInfo.class);
startActivity(i);

}
public void addDriver(View view)
{
Intent i=new Intent(DASHBOARD.this, Driverinf.class);
startActivity(i);
}

public void addBus(View view)


{
Intent i=new Intent(DASHBOARD.this, Bus.class);
startActivity(i);
}

Xml file for add student

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".StudentInfo">
<AbsoluteLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/image1"
android:alpha="0.9"
>

<TextView
android:id="@+id/t1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="4dp"
android:layout_y="55dp"
android:text="Student Name"
android:textColor="@color/white"
android:textSize="25dp"
android:textStyle="bold"
/>

<TextView
android:id="@+id/t2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="2dp"
android:layout_y="175dp"
android:text="Address"
android:textColor="@color/white"
android:textSize="25dp"
android:textStyle="bold" />

<TextView
android:id="@+id/t3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="3dp"
android:layout_y="303dp"
android:text="Contact Number"
android:textColor="@color/white"

android:textSize="25dp"
android:textStyle="bold" />

<EditText
android:id="@+id/e1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="4dp"
android:layout_y="86dp"
android:hint="Enter Student Name"
android:textColorHint="@color/white"
android:textSize="25dp"
android:textStyle="normal" />

<EditText
android:id="@+id/e2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="-2dp"
android:layout_y="208dp"
android:hint="Enter Student Address"
android:textColorHint="@color/white"
android:textSize="25dp"
android:textStyle="normal" />

<EditText
android:id="@+id/e3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="3dp"
android:layout_y="343dp"
android:hint="Enter Student Contact Number"
android:textColorHint="@color/white"
android:textSize="25dp"
android:textStyle="normal" />

<Button
android:id="@+id/b1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="-5dp"
android:layout_y="500dp"
android:text="Add Student"
android:textColor="@color/white"
android:textStyle="bold"
android:textSize="25dp" />

</AbsoluteLayout>
</LinearLayout>

Java code for add student

package com.example.collegebustracking;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

public class StudentInfo extends AppCompatActivity {


TextView t1, t2, t3;
EditText e1, e2, e3;
Button b1;
FirebaseDatabase database;
DatabaseReference ref;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
EdgeToEdge.enable(this);
setContentView(R.layout.activity_student_info);
e1 = findViewById(R.id.e1);
e2 = findViewById(R.id.e2);
e3 = findViewById(R.id.e3);
database = FirebaseDatabase.getInstance();
ref = database.getReference("students");

b1 = findViewById(R.id.b1);
b1.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
String name=e1.getText().toString().trim();
String address=e2.getText().toString().trim();
String number=e3.getText().toString().trim();
Boolean check =validateInfo(name,address,number);
if (check==true)
{
Toast.makeText(StudentInfo.this,"Data Is
Valid",Toast.LENGTH_SHORT).show();
}

else
{
Toast.makeText(StudentInfo.this,"Sorry Check Information
Again",Toast.LENGTH_SHORT).show();
}

}
});

}
private Boolean validateInfo(String name, String address,String number)
{

if(name.length()==0)
{
e1.requestFocus();
e1.setError("field cannot be empty");
return false;
} else if (!name.matches("^[a-zA-Z]+"))

{
e1.requestFocus();
e1.setError("Enter Only Alphabetical Character");
return false;

}
else if (address.isEmpty())
{
e2.requestFocus();
e2.setError("field cannot be empty");
return false;
}
else if (number.isEmpty())
{
e3.requestFocus();
e3.setError("field cannot be empty");
return false;
}
storeData(name, address, number);
return true;
}
private void storeData(String name, String address, String number) {
String id = ref.push().getKey();
Student student = new Student();
student.setId(id);
student.setName(name);
student.setAddress(address);
student.setContact(number);
ref.child(id).setValue(student)
.addOnSuccessListener(aVoid -> Log.d("Firebase", "Data successfully
written!"))
.addOnFailureListener(e -> Log.d("Firebase", "Error writing data", e));
}

Database code for add student

package com.example.collegebustracking;

public class Student {


private String id;
private String name;
private String address;
private String contact;

public Student() {
// Default constructor required for calls to
DataSnapshot.getValue(Student.class)
}

public Student(String id, String name, String address, String contact) {


this.id = id;
this.name = name;
this.address = address;
this.contact = contact;
}

// Getter and Setter methods

public String getId() {


return id;

public void setId(String id) {


this.id = id;
}

public String getName() {


return name;
}

public void setName(String name) {


this.name = name;
}

public String getAddress() {


return address;
}

public void setAddress(String address) {


this.address = address;
}

public String getContact() {


return contact;
}

public void setContact(String contact) {


this.contact = contact;
}
}

Xml file for add driver

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".StudentInfo">
<AbsoluteLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/image1"
android:alpha="0.9"
>
<TextView
android:id="@+id/t1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="4dp"
android:layout_y="55dp"
android:text="Driver Name"
android:textColor="@color/white"
android:textSize="25dp"
android:textStyle="bold"
/>

<TextView
android:id="@+id/t2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="2dp"
android:layout_y="175dp"
android:text="Bus Number"
android:textColor="@color/white"
android:textSize="25dp"
android:textStyle="bold" />

<TextView
android:id="@+id/t3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="3dp"
android:layout_y="303dp"
android:text="Contact Number"
android:textColor="@color/white"

android:textSize="25dp"
android:textStyle="bold" />

<EditText
android:id="@+id/e1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="4dp"
android:layout_y="86dp"
android:hint="Enter Driver Name"
android:textColorHint="@color/white"
android:textSize="25dp"
android:textStyle="normal" />

<EditText
android:id="@+id/e2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="-2dp"
android:layout_y="208dp"
android:hint="Enter Bus Number"
android:textColorHint="@color/white"
android:textSize="25dp"
android:textStyle="normal" />

<EditText
android:id="@+id/e3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="3dp"
android:layout_y="343dp"
android:hint="Enter Driver Contact Number"
android:textColorHint="@color/white"
android:textSize="25dp"
android:textStyle="normal" />
<Button
android:id="@+id/b1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="-5dp"
android:layout_y="500dp"
android:text="Add Bus"
android:textColor="@color/white"
android:textStyle="bold"
android:textSize="25dp" />

</AbsoluteLayout>
</LinearLayout>

Java code for add bus

package com.example.collegebustracking;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;

import com.example.collegebustracking.BusInfo;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

public class Bus extends AppCompatActivity {

private EditText e1, e2, e3;


private Button b1;
private DatabaseReference databaseBuses;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bus);

// Initialize Firebase Database


FirebaseDatabase database = FirebaseDatabase.getInstance();
databaseBuses = database.getReference("buses");

// Initialize UI elements
e1 = findViewById(R.id.e1);
e2 = findViewById(R.id.e2);
e3 = findViewById(R.id.e3);
b1 = findViewById(R.id.b1);

b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
addBus();
}
});
}
private void addBus() {
// Get the input values
String busNo = e1.getText().toString().trim();
String route = e2.getText().toString().trim();
String driverName = e3.getText().toString().trim();

// Validate the inputs


if (busNo.isEmpty()) {
e1.setError("Bus number is required");
e1.requestFocus();
return;
}

if (route.isEmpty()) {
e2.setError("Route is required");
e2.requestFocus();
return;
}

if (driverName.isEmpty()) {
e3.setError("Driver name is required");
e3.requestFocus();
return;
}

// Create a new bus object and set values using setters


BusInfo bus = new BusInfo();
bus.setBusNo(busNo);
bus.setRoute(route);
bus.setDriverName(driverName);

// Save the bus to the database


databaseBuses.child(busNo).setValue(bus);
Toast.makeText(this, "Bus added successfully", Toast.LENGTH_SHORT).show();
}
}

firebase code for add bus

package com.example.collegebustracking;
public class BusInfo {
private String busNo;
private String route;
private String driverName;

// Default constructor required for calls to DataSnapshot.getValue(BusModel.class)


public BusInfo() {
}

public BusInfo(String busNo, String route, String driverName) {


this.busNo = busNo;
this.route = route;
this.driverName = driverName;
}

public String getBusNo() {


return busNo;
}

public void setBusNo(String busNo) {


this.busNo = busNo;
}

public String getRoute() {


return route;
}

public void setRoute(String route) {


this.route = route;
}

public String getDriverName() {


return driverName;
}

public void setDriverName(String driverName) {


this.driverName = driverName;
}
}

xml code for add driver

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".StudentInfo">
<AbsoluteLayout

android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/image1"
android:alpha="0.9"
>

<TextView
android:id="@+id/t1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="4dp"
android:layout_y="55dp"
android:text="Driver Name"
android:textColor="@color/white"
android:textSize="25dp"
android:textStyle="bold"
/>

<TextView
android:id="@+id/t2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="2dp"
android:layout_y="175dp"
android:text="Bus Number"
android:textColor="@color/white"
android:textSize="25dp"
android:textStyle="bold" />

<TextView
android:id="@+id/t3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="3dp"
android:layout_y="303dp"
android:text="Contact Number"
android:textColor="@color/white"

android:textSize="25dp"
android:textStyle="bold" />
<EditText
android:id="@+id/e1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="4dp"
android:layout_y="86dp"
android:hint="Enter Driver Name"
android:textColorHint="@color/white"
android:textSize="25dp"
android:textStyle="normal" />

<EditText
android:id="@+id/e2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="-2dp"
android:layout_y="208dp"
android:hint="Enter Bus Number"
android:textColorHint="@color/white"
android:textSize="25dp"
android:textStyle="normal" />

<EditText
android:id="@+id/e3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="3dp"
android:layout_y="343dp"
android:hint="Enter Driver Contact Number"

android:textColorHint="@color/white"
android:textSize="25dp"
android:textStyle="normal" />

<Button
android:id="@+id/b1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_x="-5dp"
android:layout_y="500dp"
android:text="Add Bus"
android:textColor="@color/white"
android:textStyle="bold"
android:textSize="25dp" />

</AbsoluteLayout>
</LinearLayout>

java code for add driver

package com.example.collegebustracking;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class Driverinf extends AppCompatActivity {

EditText e1, e2, e3;


Button b1;
FirebaseDatabase database;
DatabaseReference ref;
@SuppressLint("MissingInflatedId")

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_driverinf);

e1 = findViewById(R.id.e1);
e2 = findViewById(R.id.e2);
e3 = findViewById(R.id.e3);
b1 = findViewById(R.id.b1);

database = FirebaseDatabase.getInstance();
ref = database.getReference("drivers");

b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = e1.getText().toString().trim();
String bus_no = e2.getText().toString().trim();
String number = e3.getText().toString().trim();
Boolean check = validateInfo(name, bus_no, number);

if (check==true) {
storeData(name, bus_no, number);

Toast.makeText(Driverinf.this, "Data Is Valid",


Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(Driverinf.this, "Sorry, Check Information Again",
Toast.LENGTH_SHORT).show();
}
}
});
}

private Boolean validateInfo(String name, String bus_no, String number) {


if (name.isEmpty()) {
e1.requestFocus();
e1.setError("Field cannot be empty");
return false;
}
else if (!name.matches("^[a-zA-Z]+"))
{

e1.requestFocus();
e1.setError("Enter only alphabetical characters");
return false;
} else if (number.isEmpty()) {
e3.requestFocus();
e3.setError("Field cannot be empty");
return false;
} /*else if (!number.matches("^[+][0-9]{10,13}$")) {
e3.requestFocus();
e3.setError("Correct format: +91XXXXXXXXXX");
return false;
}*/
else if (bus_no.isEmpty()) {
e2.requestFocus();
e2.setError("Field cannot be empty");
return false;
}else {
return true;
}
}

private void storeData(String name, String bus_no, String number) {


String id = ref.push().getKey();
com.example.collegebustracking.InfoDriver d = new
com.example.collegebustracking.InfoDriver();
d.setId(id);
d.setName(name);
d.setbus_no(bus_no);
d.setContactNumber(number);
ref.child(id).setValue(d);
}
}

Firebase code for add driver

package com.example.collegebustracking;
public class InfoDriver {

private String id;


private String name;
private String bus_no;
private String contactNumber;

public InfoDriver() {
// Default constructor required for calls to
DataSnapshot.getValue(Driver.class)
}

public InfoDriver(String id, String name, String bus_no, String contactNumber) {


this.id = id;
this.name = name;
this.bus_no = bus_no;
this.contactNumber = contactNumber;
}

// Getter and Setter methods

public String getId() {


return id;
}

public void setId(String id) {


this.id = id;
}

public String getName() {


return name;
}

public void setName(String name) {


this.name = name;
}

public String getbus_no() {


return bus_no;
}

public void setbus_no(String bus_no) {


this.bus_no = bus_no;
}

public String getContactNumber() {


return contactNumber;
}

public void setContactNumber(String contactNumber) {


this.contactNumber = contactNumber;
}
}

Xml code for map tracking bus

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".mapadding">

<SearchView
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:queryHint="Search Bus Drivers" />

<RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_below="@id/searchView"
android:layout_above="@id/buttonShowLiveLocation"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp" />

<Button
android:id="@+id/buttonShowLiveLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Show Live Location" />
</RelativeLayout>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.login">

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.App">

<activity android:name=".TrackBusActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<service android:name=".LocationService" />

</application>

</manifest>

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RouteInfoActivity">

<EditText
android:id="@+id/editTextStartingPoint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:hint="Starting Point"
android:inputType="text" />

<EditText
android:id="@+id/editTextDestination"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/editTextStartingPoint"
android:layout_margin="8dp"
android:hint="Destination"
android:inputType="text" />

<EditText
android:id="@+id/editTextTakeoffTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/editTextDestination"
android:layout_margin="8dp"
android:hint="Takeoff Time (hh:mm AM/PM)"
android:inputType="text" />
<TextView
android:id="@+id/textViewETA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/editTextTakeoffTime"
android:layout_margin="8dp"
android:text="ETA: "
android:textSize="16sp" />

<TextView
android:id="@+id/textViewTotalTravelTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textViewETA"
android:layout_margin="8dp"
android:text="Total Travel Time: "
android:textSize="16sp" />

<RecyclerView
android:id="@+id/recyclerViewWaypoints"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_below="@id/textViewTotalTravelTime"
android:layout_margin="8dp"
android:orientation="vertical"
tools:listitem="@layout/waypoint_item" />

<Button
android:id="@+id/buttonAddWaypoint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/recyclerViewWaypoints"
android:layout_margin="8dp"
android:layout_alignParentStart="true"
android:text="Add Waypoint" />

<Button
android:id="@+id/buttonUpdateMap"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/recyclerViewWaypoints"
android:layout_margin="8dp"
android:layout_toEndOf="@id/buttonAddWaypoint"
android:text="Update Map" />

<Button
android:id="@+id/buttonStartNavigation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/recyclerViewWaypoints"
android:layout_margin="8dp"
android:layout_alignParentEnd="true"
android:text="Start Navigation" />

<fragment
android:id="@+id/mapViewContainer"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_below="@id/buttonAddWaypoint"
class="com.google.android.gms.maps.SupportMapFragment" />

</RelativeLayout>

Java code for bus tracking


package com.example.login;

import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationCallback;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationResult;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

import java.io.IOException;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

public class RouteInfoActivity extends AppCompatActivity implements OnMapReadyCallback


{

private static final String TAG = "RouteInfoActivity";


private EditText editTextStartingPoint, editTextDestination, editTextTakeoffTime;
private TextView textViewETA, textViewTotalTravelTime;
private RecyclerView recyclerViewWaypoints;
private WaypointAdapter waypointAdapter;
private GoogleMap mMap;
private Button buttonAddWaypoint, buttonUpdateMap, buttonStartNavigation;

private Handler handler = new Handler();


private Runnable runnable;
private ArrayList<Location> busLocations = new ArrayList<>();
private int currentBusIndex = 0;
private static final long LOCATION_REFRESH_TIME = 50000; // 50 seconds interval

private DatabaseReference databaseReference;

private FusedLocationProviderClient fusedLocationClient;


private LocationCallback locationCallback;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_route_info);

// Initialize Firebase reference


databaseReference =
FirebaseDatabase.getInstance().getReference("driverschedule").child("Om_7798248200");

editTextStartingPoint = findViewById(R.id.editTextStartingPoint);
editTextDestination = findViewById(R.id.editTextDestination);
editTextTakeoffTime = findViewById(R.id.editTextTakeoffTime);
textViewETA = findViewById(R.id.textViewETA);
textViewTotalTravelTime = findViewById(R.id.textViewTotalTravelTime);
recyclerViewWaypoints = findViewById(R.id.recyclerViewWaypoints);
buttonAddWaypoint = findViewById(R.id.buttonAddWaypoint);
buttonUpdateMap = findViewById(R.id.buttonUpdateMap);
buttonStartNavigation = findViewById(R.id.buttonStartNavigation);

// Initialize RecyclerView for waypoints


waypointAdapter = new WaypointAdapter(new ArrayList<>());
recyclerViewWaypoints.setLayoutManager(new LinearLayoutManager(this));
recyclerViewWaypoints.setAdapter(waypointAdapter);

// Set up the map view


SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager()
.findFragmentById(R.id.mapViewContainer);
if (mapFragment != null) {
mapFragment.getMapAsync(this);
}

// Initialize FusedLocationProviderClient
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this);

// Create a LocationRequest
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setInterval(LOCATION_REFRESH_TIME);
locationRequest.setFastestInterval(LOCATION_REFRESH_TIME / 2);

locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

// Create a LocationCallback
locationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
if (locationResult == null) {
return;
}
for (Location location : locationResult.getLocations()) {
// Add current bus location to the list
busLocations.add(location);
// Update Firebase with the current location
updateBusLocationInFirebase(location);
}
}
};

buttonAddWaypoint.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Add a new blank waypoint
waypointAdapter.addWaypoint("");
}
});

buttonUpdateMap.setOnClickListener(new View.OnClickListener() {
@Override

public void onClick(View v) {


// Validate and parse takeoff time
String takeoffTimeStr = editTextTakeoffTime.getText().toString();
Calendar takeoffTime = parseTime(takeoffTimeStr);
if (takeoffTime == null) {
// Handle invalid time input if needed
Toast.makeText(RouteInfoActivity.this, "Invalid takeoff time
format", Toast.LENGTH_SHORT).show();
return;
}
updateMap(takeoffTime);
}
});

buttonStartNavigation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startNavigation();
}
});
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[]
permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 1 && grantResults.length > 0 && grantResults[0] ==
PackageManager.PERMISSION_GRANTED) {
startLocationUpdates();
}
}

@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;

// Start listening for location updates


startLocationUpdates();
}

private void startLocationUpdates() {


if (ContextCompat.checkSelfPermission(this,

Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
fusedLocationClient.requestLocationUpdates(LocationRequest.create(),
locationCallback, null);
} else {
ActivityCompat.requestPermissions(this, new
String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
}
}

private void updateMap(Calendar takeoffTime) {


String startingPoint = editTextStartingPoint.getText().toString();
String destination = editTextDestination.getText().toString();
List<String> waypoints = waypointAdapter.getWaypoints();

if (startingPoint.isEmpty() || destination.isEmpty()) {
Toast.makeText(this, "Please enter both starting point and destination",
Toast.LENGTH_SHORT).show();
return;
}

// Geocode starting point


geocodeAddress(startingPoint, new OnGeocodeCompleteListener() {

@Override
public void onGeocodeComplete(LatLng startingLatLng) {
// Geocode destination
geocodeAddress(destination, new OnGeocodeCompleteListener() {
@Override
public void onGeocodeComplete(LatLng destinationLatLng) {
// Geocode waypoints
geocodeWaypoints(waypoints, new
OnGeocodeWaypointsCompleteListener() {
@Override
public void onGeocodeWaypointsComplete(List<LatLng>
waypointLatLngs) {
// Clear existing markers
mMap.clear();

// Add marker for starting point


mMap.addMarker(new
MarkerOptions().position(startingLatLng).title("starting point”));

mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(startingLatLng, 12));

// Add marker for destination


mMap.addMarker(new
MarkerOptions().position(destinationLatLng).title("destination"));

// Add markers for waypoints


for (LatLng waypointLatLng : waypointLatLngs) {
mMap.addMarker(new
MarkerOptions().position(waypointLatLng).title("Waypoint"));
}

// Calculate total distance and update ETA and total


travel time
calculateETAAndTravelTime(startingLatLng,
destinationLatLng, waypointLatLngs, takeoffTime);
}
});
}
});
}
});
}

private void geocodeAddress(String address, OnGeocodeCompleteListener listener) {


Geocoder geocoder = new Geocoder(this);
try {
List<android.location.Address> addresses =
geocoder.getFromLocationName(address, 1);
if (addresses != null && !addresses.isEmpty()) {
android.location.Address location = addresses.get(0);
LatLng latLng = new LatLng(location.getLatitude(),
location.getLongitude());
listener.onGeocodeComplete(latLng);
} else {
Toast.makeText(this, "Geocoding failed for address: " + address,
Toast.LENGTH_SHORT).show();
}
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(this, "Geocoding error: " + e.getMessage(),
Toast.LENGTH_SHORT).show();
}
}

private void geocodeWaypoints(List<String> waypoints,


OnGeocodeWaypointsCompleteListener listener) {
List<LatLng> waypointLatLngs = new ArrayList<>();
Geocoder geocoder = new Geocoder(this);

new Thread(() -> {


for (String waypoint : waypoints) {
try {
List<Address> addresses = geocoder.getFromLocationName(waypoint,
1);
if (addresses != null && !addresses.isEmpty()) {
Address location = addresses.get(0);
LatLng latLng = new LatLng(location.getLatitude(),
location.getLongitude());
waypointLatLngs.add(latLng);
}
} catch (IOException e) {
e.printStackTrace();
}
}

runOnUiThread(() -> listener.onGeocodeWaypointsComplete(waypointLatLngs));


}).start();
}

private void calculateETAAndTravelTime(LatLng startingLatLng, LatLng


destinationLatLng, List<LatLng> waypointLatLngs, Calendar takeoffTime) {
// Calculate the total distance and time
float[] results = new float[1];
LatLng previousLatLng = startingLatLng;
float totalDistance = 0;

// Calculate distance for waypoints


for (LatLng waypointLatLng : waypointLatLngs) {
Location.distanceBetween(previousLatLng.latitude, previousLatLng.longitude,
waypointLatLng.latitude, waypointLatLng.longitude, results);
totalDistance += results[0];
previousLatLng = waypointLatLng;
}

// Calculate distance to destination


Location.distanceBetween(previousLatLng.latitude, previousLatLng.longitude,
destinationLatLng.latitude, destinationLatLng.longitude, results);
totalDistance += results[0];

// Assuming an average speed of 50 km/h


float averageSpeedKmH = 50.0f;
float totalTravelTimeHours = totalDistance / 1000 / averageSpeedKmH;

// Calculate ETA
Calendar eta = (Calendar) takeoffTime.clone();
eta.add(Calendar.MINUTE, (int) (totalTravelTimeHours * 60));

// Update UI
textViewETA.setText("ETA: " + eta.getTime().toString());
textViewTotalTravelTime.setText(String.format("Total Travel Time: %.2f hours",
totalTravelTimeHours));
}
private void updateBusLocationInFirebase(Location location) {

// Create a map to hold the location data


HashMap<String, Object> locationData = new HashMap<>();
locationData.put("latitude", location.getLatitude());
locationData.put("longitude", location.getLongitude());

// Use push() to generate a unique key and add the location data to Firebase
databaseReference.child("currentLocations").push().setValue(locationData)
.addOnSuccessListener(aVoid -> Log.d(TAG, "Location updated in
Firebase"))
.addOnFailureListener(e -> Log.e(TAG, "Failed to update location in
Firebase", e));
}

private void startNavigation() {


if (busLocations.isEmpty()) {
Toast.makeText(this, "No bus location data available",
Toast.LENGTH_SHORT).show();
return;
}

// Start showing bus locations on the map


animateBusLocations();
}

private void animateBusLocations() {


if (mMap == null || busLocations.isEmpty()) return;

// Animate bus locations on the map


runnable = new Runnable() {
@Override
public void run() {
if (currentBusIndex < busLocations.size()) {
Location busLocation = busLocations.get(currentBusIndex);
LatLng latLng = new LatLng(busLocation.getLatitude(),
busLocation.getLongitude());

// Clear previous bus marker only if it's not the first location
if (currentBusIndex > 0) {
// mMap.clear(); // Don't clear entire map, only update markers
// Optionally, clear previous markers and polylines if needed
}

// Add or update bus marker


mMap.addMarker(new MarkerOptions()
.position(latLng)
.title("Bus Location")

.icon(BitmapDescriptorFactory.fromResource(R.drawable.img_8)));

// Center camera on bus location if it's the first location


if (currentBusIndex == 0) {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng,
15));
}

currentBusIndex++;
handler.postDelayed(this, LOCATION_REFRESH_TIME);
} else {

currentBusIndex = 0; // Reset index for next use


}
}
};

handler.postDelayed(runnable, LOCATION_REFRESH_TIME);
}

@Override
protected void onDestroy() {
super.onDestroy();
// Remove location updates when activity is destroyed
fusedLocationClient.removeLocationUpdates(locationCallback);
// Remove any pending runnables
handler.removeCallbacksAndMessages(null);
}

// Interfaces for geocode completion listeners


private interface OnGeocodeCompleteListener {
void onGeocodeComplete(LatLng latLng);
}

private interface OnGeocodeWaypointsCompleteListener {


void onGeocodeWaypointsComplete(List<LatLng> waypointLatLngs);
}
private Calendar parseTime(String timeString) {
SimpleDateFormat timeFormat = new SimpleDateFormat("hh:mm a",
Locale.getDefault());
Calendar calendar = Calendar.getInstance();
try {
Date date = timeFormat.parse(timeString);
if (date != null) {
calendar.setTime(date);
}
} catch (ParseException e) {
e.printStackTrace();
Toast.makeText(this, "Invalid time format. Please use hh:mm AM/PM format.",
Toast.LENGTH_SHORT).show();
}
return calendar;
}

package com.example.login;

import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationCallback;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationResult;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;

import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

public class RouteInfoActivity extends AppCompatActivity implements OnMapReadyCallback


{

private static final String TAG = "RouteInfoActivity";


private EditText editTextStartingPoint, editTextDestination, editTextTakeoffTime;
private TextView textViewETA, textViewTotalTravelTime;
private RecyclerView recyclerViewWaypoints;
private WaypointAdapter waypointAdapter;
private GoogleMap mMap;
private Button buttonAddWaypoint, buttonUpdateMap, buttonStartNavigation;

private Handler handler = new Handler();


private Runnable runnable;
private ArrayList<Location> busLocations = new ArrayList<>();
private int currentBusIndex = 0;
private static final long LOCATION_REFRESH_TIME = 50000; // 50 seconds interval

private DatabaseReference databaseReference;

private FusedLocationProviderClient fusedLocationClient;


private LocationCallback locationCallback;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_route_info);

// Initialize Firebase reference


databaseReference =
FirebaseDatabase.getInstance().getReference("driverschedule").child("Om_7798248200");

editTextStartingPoint = findViewById(R.id.editTextStartingPoint);
editTextDestination = findViewById(R.id.editTextDestination);
editTextTakeoffTime = findViewById(R.id.editTextTakeoffTime);
textViewETA = findViewById(R.id.textViewETA);
textViewTotalTravelTime = findViewById(R.id.textViewTotalTravelTime);
recyclerViewWaypoints = findViewById(R.id.recyclerViewWaypoints);
buttonAddWaypoint = findViewById(R.id.buttonAddWaypoint);
buttonUpdateMap = findViewById(R.id.buttonUpdateMap);
buttonStartNavigation = findViewById(R.id.buttonStartNavigation);

// Initialize RecyclerView for waypoints


waypointAdapter = new WaypointAdapter(new ArrayList<>());
recyclerViewWaypoints.setLayoutManager(new LinearLayoutManager(this));

recyclerViewWaypoints.setAdapter(waypointAdapter);

// Set up the map view


SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager()
.findFragmentById(R.id.mapViewContainer);
if (mapFragment != null) {
mapFragment.getMapAsync(this);
}

// Initialize FusedLocationProviderClient
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this);

// Create a LocationRequest
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setInterval(LOCATION_REFRESH_TIME);
locationRequest.setFastestInterval(LOCATION_REFRESH_TIME / 2);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

// Create a LocationCallback
locationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
if (locationResult == null) {
return;
}
for (Location location : locationResult.getLocations()) {
// Add current bus location to the list
busLocations.add(location);
// Update Firebase with the current location
updateBusLocationInFirebase(location);
}
}
};

buttonAddWaypoint.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Add a new blank waypoint
waypointAdapter.addWaypoint("");
}
});

buttonUpdateMap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Validate and parse takeoff time
String takeoffTimeStr = editTextTakeoffTime.getText().toString();
Calendar takeoffTime = parseTime(takeoffTimeStr);
if (takeoffTime == null) {
// Handle invalid time input if needed
Toast.makeText(RouteInfoActivity.this, "Invalid takeoff time
format", Toast.LENGTH_SHORT).show();
return;
}
updateMap(takeoffTime);
}
});

buttonStartNavigation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startNavigation();
}
});
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[]
permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == 1 && grantResults.length > 0 && grantResults[0] ==
PackageManager.PERMISSION_GRANTED) {
startLocationUpdates();
}
}

@Override
public void onMapReady(GoogleMap googleMap) {

mMap = googleMap;

// Start listening for location updates


startLocationUpdates();
}

private void startLocationUpdates() {


if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
fusedLocationClient.requestLocationUpdates(LocationRequest.create(),
locationCallback, null);
} else {
ActivityCompat.requestPermissions(this, new
String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
}
}

private void updateMap(Calendar takeoffTime) {


String startingPoint = editTextStartingPoint.getText().toString();
String destination = editTextDestination.getText().toString();
List<String> waypoints = waypointAdapter.getWaypoints();

if (startingPoint.isEmpty() || destination.isEmpty()) {
Toast.makeText(this, "Please enter both starting point and destination",
Toast.LENGTH_SHORT).show();
return;
}

// Geocode starting point


geocodeAddress(startingPoint, new OnGeocodeCompleteListener() {
@Override
public void onGeocodeComplete(LatLng startingLatLng) {
// Geocode destination
geocodeAddress(destination, new OnGeocodeCompleteListener() {
@Override
public void onGeocodeComplete(LatLng destinationLatLng) {
// Geocode waypoints
geocodeWaypoints(waypoints, new
OnGeocodeWaypointsCompleteListener() {
@Override
public void onGeocodeWaypointsComplete(List<LatLng>
waypointLatLngs) {
// Clear existing markers
mMap.clear();

// Add marker for starting point


mMap.addMarker(new

MarkerOptions().position(startingLatLng).title("Starting Point"));

mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(startingLatLng, 12));

// Add marker for destination


mMap.addMarker(new
MarkerOptions().position(destinationLatLng).title("Destination"));

// Add markers for waypoints


for (LatLng waypointLatLng : waypointLatLngs) {
mMap.addMarker(new
MarkerOptions().position(waypointLatLng).title("Waypoint"));
}

// Calculate total distance and update ETA and total


travel time
calculateETAAndTravelTime(startingLatLng,
destinationLatLng, waypointLatLngs, takeoffTime);
}
});
}
});
}

});
}

private void geocodeAddress(String address, OnGeocodeCompleteListener listener) {


Geocoder geocoder = new Geocoder(this);
try {
List<android.location.Address> addresses =
geocoder.getFromLocationName(address, 1);
if (addresses != null && !addresses.isEmpty()) {
android.location.Address location = addresses.get(0);
LatLng latLng = new LatLng(location.getLatitude(),
location.getLongitude());
listener.onGeocodeComplete(latLng);
} else {
Toast.makeText(this, "Geocoding failed for address: " + address,
Toast.LENGTH_SHORT).show();
}
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(this, "Geocoding error: " + e.getMessage(),
Toast.LENGTH_SHORT).show();
}
}

private void geocodeWaypoints(List<String> waypoints,


OnGeocodeWaypointsCompleteListener listener) {
List<LatLng> waypointLatLngs = new ArrayList<>();
Geocoder geocoder = new Geocoder(this);

new Thread(() -> {


for (String waypoint : waypoints) {
try {
List<Address> addresses = geocoder.getFromLocationName(waypoint,
1);
if (addresses != null && !addresses.isEmpty()) {
Address location = addresses.get(0);
LatLng latLng = new LatLng(location.getLatitude(),
location.getLongitude());
waypointLatLngs.add(latLng);
}
} catch (IOException e) {
e.printStackTrace();
}
}

runOnUiThread(() -> listener.onGeocodeWaypointsComplete(waypointLatLngs));


}).start();
}

private void calculateETAAndTravelTime(LatLng startingLatLng, LatLng


destinationLatLng, List<LatLng> waypointLatLngs, Calendar takeoffTime) {
// Calculate the total distance and time
float[] results = new float[1];
LatLng previousLatLng = startingLatLng;
float totalDistance = 0;

// Calculate distance for waypoints


for (LatLng waypointLatLng : waypointLatLngs) {
Location.distanceBetween(previousLatLng.latitude, previousLatLng.longitude,
waypointLatLng.latitude, waypointLatLng.longitude, results);
totalDistance += results[0];
previousLatLng = waypointLatLng;
}

// Calculate distance to destination


Location.distanceBetween(previousLatLng.latitude, previousLatLng.longitude,
destinationLatLng.latitude, destinationLatLng.longitude, results);
totalDistance += results[0];

// Assuming an average speed of 50 km/h

float averageSpeedKmH = 50.0f;


float totalTravelTimeHours = totalDistance / 1000 / averageSpeedKmH;

// Calculate ETA
Calendar eta = (Calendar) takeoffTime.clone();
eta.add(Calendar.MINUTE, (int) (totalTravelTimeHours * 60));

// Update UI
textViewETA.setText("ETA: " + eta.getTime().toString());
textViewTotalTravelTime.setText(String.format("Total Travel Time: %.2f hours",
totalTravelTimeHours));
}

private void updateBusLocationInFirebase(Location location) {


// Create a map to hold the location data
HashMap<String, Object> locationData = new HashMap<>();
locationData.put("latitude", location.getLatitude());
locationData.put("longitude", location.getLongitude());

// Use push() to generate a unique key and add the location data to Firebase
databaseReference.child("currentLocations").push().setValue(locationData)
.addOnSuccessListener(aVoid -> Log.d(TAG, "Location updated in
Firebase"))
.addOnFailureListener(e -> Log.e(TAG, "Failed to update location in
Firebase", e));
}

private void startNavigation() {


if (busLocations.isEmpty()) {
Toast.makeText(this, "No bus location data available",
Toast.LENGTH_SHORT).show();
return;
}

// Start showing bus locations on the map


animateBusLocations();
}

private void animateBusLocations() {


if (mMap == null || busLocations.isEmpty()) return;

// Animate bus locations on the map


runnable = new Runnable() {
@Override
public void run() {
if (currentBusIndex < busLocations.size()) {
Location busLocation = busLocations.get(currentBusIndex);
LatLng latLng = new LatLng(busLocation.getLatitude(),
busLocation.getLongitude());

// Clear previous bus marker only if it's not the first location
if (currentBusIndex > 0) {
// mMap.clear(); // Don't clear entire map, only update markers
// Optionally, clear previous markers and polylines if needed
}

// Add or update bus marker


mMap.addMarker(new MarkerOptions()
.position(latLng)
.title("Bus Location")

.icon(BitmapDescriptorFactory.fromResource(R.drawable.img_8)));

// Center camera on bus location if it's the first location


if (currentBusIndex == 0) {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng,
15));
}

currentBusIndex++;
handler.postDelayed(this, LOCATION_REFRESH_TIME);
} else {
currentBusIndex = 0; // Reset index for next use
}
}
};

handler.postDelayed(runnable, LOCATION_REFRESH_TIME);
}

@Override
protected void onDestroy() {
super.onDestroy();
// Remove location updates when activity is destroyed
fusedLocationClient.removeLocationUpdates(locationCallback);
// Remove any pending runnables
handler.removeCallbacksAndMessages(null);
}

// Interfaces for geocode completion listeners


private interface OnGeocodeCompleteListener {
void onGeocodeComplete(LatLng latLng);
}

private interface OnGeocodeWaypointsCompleteListener {


void onGeocodeWaypointsComplete(List<LatLng> waypointLatLngs);
}
private Calendar parseTime(String timeString) {
SimpleDateFormat timeFormat = new SimpleDateFormat("hh:mm a",
Locale.getDefault());
Calendar calendar = Calendar.getInstance();
try {
Date date = timeFormat.parse(timeString);
if (date != null) {
calendar.setTime(date);
}
} catch (ParseException e) {
e.printStackTrace();
Toast.makeText(this, "Invalid time format. Please use hh:mm AM/PM format.",
Toast.LENGTH_SHORT).show();
}
return calendar;
}
Chapter 9
Screenshot
Weblinks:

1) https://www.freeprojectz.com/project-source-code-database-download/canteen-management-system-project
2) https://www.otootuitions.com/
3) https://www.javatpoint.com/android-tutorial
Chapter 10

Conclusion

To assist students in understanding and learning subject material from the course. To help students achieve
their personal academic goals by preparing them for upcoming class material. To help students become
independent learners. To deploy the exact solution for your users, giving them the right entry path is
mandatory. Once you successfully put them on the right path, your users won’t have any difficulty using the
application. Smart search is one of the options that app owners should include in their applications. Through
smart search, the user can get to the place where they want to be.

You might also like