Lab on Android Application Development Theory
Lab on Android Application Development Theory
Installation and setup of java development kit (JDK), setup android SDK, setup
eclipse IDE, setup android development tools (ADT) plugins, create android virtual
device
Go to the Oracle site and open the Java SE download page. Under the latest version of Java
Platform, Standard Edition, click on the JDK download button.
Next, click on the Accept License Agreement button and choose your version of Java for Windows (32-
bit or 64-bit) to proceed with downloading the JDK executable file.
In this step, we will be running the executable JDK file (It will be a file with .exe as an extension) once
the download is done. This installs JDK as well as JRE. For running this file on Windows, we will need
Administrator rights. To begin the installation, we need to double-click on the downloaded file,
Click on Next to proceed with the installation, and follow the Installation guide provided for any
queries.
To recover some of our system’s disk space, it is good practice to delete the downloaded exe file once
the download has been done.
JDK gets installed in the C directory of our system by default having the path “C:\Program
Files\Java\jdk-11.0”. If we make any change to this path at all, we need to make a note of it as
it will be required in the upcoming steps.
We will need to update our system’s Environment variables with our installed JDK bin path to
run the Java programs because while executing the programs, the command prompt will look
for the complete JDK bin path.
The PATH variable in our system provides the exact location of executables that will be used for
running Java programs, such as javac and java. The CLASSPATH variable provides us with the
library files location.
If we do not set the PATH variable, we will specify the full path to the JDK bin every time we run
a program.
Inside Properties, in the left-side panel, select Advanced System Settings, and here choose the option
Environment Variables.
Click on New, and type PATH in the Variable Name, and enter the path of the bin of installed
JDK in the Variable Value field.
If we already have the PATH variable, we can edit it by adding it to the existing values.
Open the command prompt and enter the command “java –version”, and if it runs successfully,
Java has been successfully installed.
Now that we have seen the steps to install JDK, let the programming fun begin!
Within Android Studio, you can install the Android 12 SDK as follows:
In this page, you will learn what softwares are required for running an android application on eclipse
IDE. Here, you will be able to learn how to install the android SDK and ADT plugin for Eclipse IDE. Let's
see the list of software required to setup android for eclipse IDE manually.
You can download the JDK and install it, which is pretty easy. After that, you just have to set PATH and
JAVA_HOME variables to the folder where you have java and javac.
Note for Windows Users: If you installed the JDK in C:\jdk1.6.0_15 then you will have to add the
following two lines in your C:\autoexec.bat file.
set PATH=C:\jdk1.6.0_15\bin;%PATH%
set JAVA_HOME=C:\jdk1.6.0_15
After you have successfully installed the Android SDK, it is time to configure it. After installing the
Android SDK, you will get a window like this:
Just de-select the Documentation for Android SDK and Samples for SDK packages if you want to
reduce the installation size and time. Click on Install 7 packages to continue with the installation.
You will get a dialogue box like this:
It will take some time to install, so in the meanwhile you could do some other task to kill the time.
How long will it take? Well, it depends on the speed of your Internet connection. Once it is done, you
can close the SDK manager.
Install the latest version of Eclipse. After successful installation, it should display a window like this:
Here you will learn to install the Android Development Tool plugin for Eclipse. To do this, you have to
click on Help > Software Updates > Install New Software. This will display the following dialogue
box.
Just click on the Add button as shown in the picture and add https://dl-
ssl.google.com/android/eclipse/ as the location. When you press OK, Eclipse will start to search
for the required plug-in and finally it will list the found plug-ins.
The last step is to create Android Virtual Device, which you will use to test your Android applications.
To do this, open Eclipse and Launch Android AVD Manager from options Window > AVD
Manager and click on New which will create a successful Android Virtual Device. Use the screenshot
below to enter the correct values.
In android development, we need an android device to run the application. So, developers of Android
Studio provide an option to install android virtual device to run it. In this article, we will learn how to
install Android Virtual Device (AVD).
Step 3: A pop-up window will be there and here we select the category Phone because we are creating
android app for mobile and select the model of mobile phone we want to install.
Step 4: Here we select the android version to download like Q, Pie, Oreo etc and click Next button.
Step 6: Now we can select the virtual device we want to run as emulator can click on the run icon.
Step 7: Finally our virtual device is ready to run our android app.
Practical 2
Create “Hello World” application. That will display “Hello World” in the middle of the screen
using TextView Widget in the red color
Step-1
The first step is to create a simple Android Application using Android studio. When you click on Android
studio icon,
Step-2
You can start your application development by calling start a new android studio project. in a new
installation frame should ask Application name, package information and location of the project.−
Step-3
After entered application name, it going to be called select the form factors your application runs on,
here need to specify Minimum SDK, in our tutorial, I have declared as API23: Android
6.0(Mashmallow)
Step-4
The next level of installation should contain selecting the activity to mobile, it specifies the default
layout for Applications.
Step-5
At the final stage it going to be open development tool to write the application code.
Prac�cal 3
1. TextView
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
2. EditText
• Purpose: A user-editable text field where the user can input data (e.g., username, password).
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
3. Buton
• Usage: Used for ac�ons like submi�ng a form, naviga�ng to another ac�vity, or any user-triggered task.
<Buton
android:id="@+id/buton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
4. ImageView
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_example" />
5. CheckBox
• Purpose: A box that can be either checked or unchecked. It allows users to select one or more op�ons.
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
6. RadioButon
• Purpose: Similar to CheckBox but works as part of a group where only one op�on can be selected at a �me.
<RadioButon
android:id="@+id/radioButon1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
7. Spinner
• Usage: Used to allow users to choose from a list of op�ons (e.g., country selec�on).
<Spinner
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
8. SeekBar
• Purpose: A slider widget that allows the user to select a value from a con�nuous range.
<SeekBar
android:id="@+id/seekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="50" />
9. ProgressBar
• Usage: O�en used when showing the progress of long-running tasks (e.g., downloading, file copying).
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="false"
android:max="100"
android:progress="0" />
Practical 4
Following are the important attributes related to TextView control. You can check Android official
documentation for complete list of attributes and related methods which you can use to change these
attributes are run time.
1 android:id
2 android:capitalize
If set, specifies that this TextView has a textual input method and should automatically
capitalize what the user types.
3 android:cursorVisible
4 android:editable
5 android:fontFamily
6 android:gravity
Specifies how to align the text by the view's x- and/or y-axis when the text is smaller than the
view.
7 android:hint
8 android:inputType
The type of data being placed in a text field. Phone, Date, Time, Number, Password etc.
10 android:maxWidth
The android.widget.ScrollView class provides the functionality of scroll view. ScrollView is used to scroll
the child elements of palette inside ScrollView. Android supports vertical scroll view as default scroll
view. Vertical ScrollView scrolls elements vertically.
Add some strings inside the strings.xml file to display those strings in the app.
strings.xml
Practical 6
Create login application where you will have to validate username and passwords
Till the username and password is not validated, login button should remain
disabled
Components of Calculator:
• TextView: This is used to display the current input or result of the calculation.
• Button Listeners: Buttons are assigned listeners that call methods to append
numbers to the current input, set the operator, or calculate the result.
Working of application :
• When you run the app, the calculator will display on the screen. You can press
the numeric buttons (0-9), perform basic operations (addition, subtraction,
multiplication, division), and get the result by pressing the "=" button.
Key Points :
• State Management: The calculator needs to keep track of the current input,
selected operator, and operands.
An intent is a messaging object used to request any action from another app component.
Intents facilitate communication between different components in several ways. The intent is
used to launch an activity, start the services, broadcast receivers, display a web page, dial a
phone call, send messages from one activity to another activity, and so on.
1. Implicit
2. Explicit
Implicit Intent
Implicit Intent doesn’t specify the component. In such a case, intent provides information on
available components provided by the system that is to be invoked. For example, you may write
the following code to view the webpage.
Syntax:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("https://www.google.com/"));
startActivity(intent);
Explicit Intent
Explicit Intent specifies the component. In such a case, intent provides the external class to be
invoked.
Syntax:
Intent i = new Intent(getApplicationContext(), ActivityTwo.class);
startActivity(i);
How an implicit intent is delivered through the system to start another activity: [1] Activity
A creates an Intent with an action description and passes it to startActivity(). [2] The
Android System searches all apps for an intent filter that matches the intent. When a match is
found, [3] the system starts the matching activity (Activity B) by invoking
its onCreate() method and passing it the Intent.