Gaurav Jain Report Java For Android
Gaurav Jain Report Java For Android
ON
JAVA FOR ANDROID
SUBMITTED IN PARTICUALR FULFILMENT OF THE REQIREMENT FOR THE AWARD
OF THE DEGREE OF
BACHELOR OF ENGINEERING
(Computer Science & Engineering)
JUNE-JULY,2022
SUBMITTED BY :
NAME : GAURAV JAIN
UNIVERSITY UID : 21BCS1013
CANDIDATE'S DECLARATION
I GAURAV JAIN hereby declare that I have undertaken Summer Training and developed project
titled unit converter in Java during a period from 15-06-2022 to 29-6-2022 in partial fulfilment
of requirements for the award of degree of B.E (COMPUTER SCIENCE & ENGINEERING) at
The satisfaction that accompanies the successful completion of this project would be incomplete
without the mention of the people who made it possible, without whose constant guidance and
encouragement would have made efforts go in vain.
I would like to extend my sincere and heartfelt gratitude to my teacher Mr. Manjeet Singh who
has helped me in this endeavor and has always been very cooperative. Without his help,
cooperation, guidance and encouragement, the project couldn’t have been what it evolved to be.
I extend my heartfelt thanks to Mrs. Shweta Aggarwal for her guidance and constant supervision
, as well as for providing me with the necessary information regarding the project.
I am also thankful to my parents for their cooperation and encouragement.
At last, gratitude to all my friends who helped me (directly or indirectly) to complete this project
within a limited time frame.
ABSTRACT
Although SI unit is universally accepted, science and engineering works are not measured with
the same units all over the world. Some nations’ code specifies meter as unit of length and some
as feet. It means that measurement units are not same in all parts of the world.
In the manual system of unit conversion, there is high chance of occurrence of error, and it is not
user-friendly. Further, it is tedious and time consuming. Only the experts or educated person is
capable of unit conversion. But, it doesn’t need any skilled person to use this Unit Converter
Android app. Anybody can convert any unit to desired equivalent unit easily and accurately.
In this project UNIT CONVERTER Application named Measurements , a user friendly interface
in android environment for converting centimeter into inches , feets , yards and miles.
Centimeter being the smaller convenient measurement in the mathematics , is used as base where
we can convert the centimeters into any of the following 4 units.
CONTENTS
Topic Page No.
Certificates by Coursera i
Candidate’s Declaration ii
Abstract (left) iii
Acknowledgement vi
About the Course v
List of Figures vi
List of Tables vii
Definitions, Acronyms and Abbreviations viii
CHAPTER 1 INTRODUCTION 1-19
(This chapter should include the background of the topic of the training, theoretical
explanation about the same, SW/HW tools learned)
1.1 1
1.2 4
1.3 7
1.4 14
CHAPTER 2 TRAINING WORK UNDERTAKEN 20-__
(This chapter should include the sequential learning steps, methodology followed and project
undertaken, if any)
2.1 20
2.2 __
2.3 __
2.4 __
2.5 __
CHAPTER 3 RESULTS AND DISCUSSION __-__
(This chapter should include any results and the related discussions for the projects made during
training. If no project has been made the results and snapshots for the tools learnt should be
included)
3.1 __
3.2 __
3.3 __
3.4
CHAPTER 4 CONCLUSION AND FUTURE SCOPE __-__
4.1 Conclusion __
4.2 Future Scope __
REFERENCES __
APPENDIX (Program or any additional information regarding training) __
List of Figures
Chapter 2 :
Figure 2.1 Calculator UI
Chapter 3 :
Figure 3.1 Widget Screen
Figure 3.2 UI
List of Tables
Chapter 1:
Table 1.1 Android Versions
About the Course
This course offered by Coursera and sponsored by Chandigarh University helped me to learn the
core features and classes from the Java Programming Language that are used in Android, which
is the dominant platform for developing mobile apps.
This course covers the key Java programming language features that control the flow of
execution through an app, enable access to structured data such as Java Arrays and common
classes in Java collection Framework, such as Array List and HashMap , group related operations
and data into classes and interfaces such as Java primitive and user defined types, fields,
methods, generic parameters, and exceptions , customize the behaviour of existing classes via
inheritance and polymorphism such as subclassing and overriding virtual methods , generic
parameters and exceptions .
At the end we can apply all these Java features in the context of core Android components such
as Activities and basic UI elements by using the common tools like Android Studio used in
Developing Java Programs and useful Android Apps .
We were also having one Guided project in which we were able to make a simple Calculator
using Java and Android Studio.
Android is an open-source operating System for mobile devices such as smart-phones and
tablet, computers. Android offers a unified approach to application development for mobile
devices which means developers need to develop only for Android, and their applications
should be able to run on different devices powered by android. Android was developed by the
Open Handset Alliance (OHA) , led by Google, and other companies. Android is mainly
based on direct manipulation, using touch gestures that loses correspond to real world
actions. It provides us with the manipulate on-screen object, along with a virtual keyboard for
text input.
Android was initially developed by Android Inc., the code names of android ranges from A to N.
Founded by Andy Rubin in Palo Alto,California, United States in Oct 2003. Android word is
actually reffered to as robot Android was named after the nickname of Andy Rubin by their co-
workers for his love for robot. Google acquired android Incorporation on 17 th Aug,2005.
Android was developed by the Open Handset Alliance(OHA) for camera phone, led by Google,
and other companies. But shifted to smart-phones due to low market of cameras at that time.
HTC launches the first android mobile. In 2010,Google launched it’s Nexus series of devices in
smart-phone world with android OS.
1.4 Android Versions
There are a total of 18 versions of Android available. Google has named all the versions of
Android after either sweet treats or desserts, in alphabetical order. Below is the list of all the
Android versions with their special names.
Each project in Android Studio contains one or more modules with source code files and
resource files.
Types of modules include:
Android app modules
Library modules
Google App Engine modules
By default, Android Studio displays your project files in the Android project view. This view
is organized by modules to provide quick access to your project's key source files. All the
build files are visible at the top level under Gradle Scripts and each app module contains the
following folders:
Manifests: Contains the AndroidManifest.xml file.
Java: Contains the Java source code files, including JUnit test code.
Res: Contains all non-code resources, such as XML layouts, UI strings, and bitmap
images.
Unit Converter is an app that lets you do exactly what its name suggests: convert all kinds of
units, regardless of what you’re trying to measure. You can convert measurement units of length,
weight, temperature, speed, power, voltage, and many others.
Although SI unit is universally accepted, science and engineering works are not measured with
the same units all over the world. Some nations’ code specifies meter as unit of length and some
as feet. It means that measurement units are not same in all parts of the world.
In the manual system of unit conversion, there is high chance of occurrence of error, and it is not
user-friendly. Further, it is tedious and time consuming. Only the experts or educated person is
capable of unit conversion. But, it doesn’t need any skilled person to use this Unit Converter
Android app. Anybody can convert any unit to desired equivalent unit easily and accurately.
CHAPTER 3 RESULTS AND DISCUSSION
3.2 Design
The UI design can be created easily with the help of the following UI components: The layout
consist of basically 2 editTextView , 2 text view followed by 4 buttons to perform the main
action of conversion.
3.3 Implementation
Create a new project and name it . I named my project measurements . After doing so we will
See two files opened in front of us , so in the file activity_main.xml we can edit the layout of our
app . MainActivity.java is the file where all the logic of our code exists . Now if you want to
change the icon of our app then change it in AndroidMainfest.xml.
MainActivity.java
package com.example.measurements;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
private Button button;
private Button button2;
private Button button3;
private Button button4;
private TextView textview;
private EditText editTextTextPersonName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button=findViewById(R.id.button);
button2=findViewById(R.id.button2);
button3=findViewById(R.id.button3);
button4=findViewById(R.id.button4);
textview=findViewById(R.id.textView);
editTextTextPersonName=findViewById(R.id.editTextTextPersonName);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String s = editTextTextPersonName.getText().toString();
int cm = Integer.parseInt(s);
double inch = 0.393*cm;
textview.setText("The corresponding centimeter in inches are " +inch);
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String s = editTextTextPersonName.getText().toString();
int cm = Integer.parseInt(s);
double yard = 0.01093613*cm;
textview.setText("The corresponding centimeter in yard are " +yard);
}
}
);
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String s = editTextTextPersonName.getText().toString();
int cm = Integer.parseInt(s);
double feet = 0.0328084 * cm;
textview.setText("The corresponding centimeter in feets are "+
feet);
}
}
);
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String s = editTextTextPersonName.getText().toString();
int cm = Integer.parseInt(s);
double miles = 0.00000621 * cm;
textview.setText("The corresponding centimeter in feets are " + miles);
}
});
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:id="@+id/editTextTextPersonName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.12" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="INCHES "
app:layout_constraintBottom_toTopOf="@+id/button2"
app:layout_constraintEnd_toStartOf="@+id/button3"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="YARD"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/button4"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName"
app:layout_constraintVertical_bias="0.365" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="FEET"
app:layout_constraintBottom_toTopOf="@+id/button4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.772"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName" />
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="MILES "
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.773"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName"
app:layout_constraintVertical_bias="0.365" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName"
app:layout_constraintVertical_bias="0.015" />
<EditText
android:id="@+id/editTextTextPersonName2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text=" Enter the value in CENTIMETER"
android:textSize="24sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.001" />
</androidx.constraintlayout.widget.ConstraintLayout>
AndroidMainfests.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.measurements">
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@drawable/preview"
android:label="@string/app_name"
android:roundIcon="@drawable/preview"
android:supportsRtl="true"
android:theme="@style/Theme.Measurements"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</manifest>
3.5 Output :
Figure 3.1 Widget Screen
Figure 3.2 UI
CHAPTER 4 CONCLUSION AND FUTURE SCOPE
4.1 Conclusion:
After completing this project, I concluded that this project was the good opportunity to
implement my information that I have learnt during my internship program. This project is more
informative and more helpful for understanding the concept of the android app development.
This project is only a small and easy one but it is enough to implement my concept. I can further
try much harder to make much more efficient and useful app that can benefit to other. of Android
development