Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
15 views

Lab on Android Application Development Theory

The document provides a comprehensive guide for setting up the Java Development Kit (JDK), Android SDK, Eclipse IDE, and Android Development Tools (ADT) plugins, along with creating an Android Virtual Device (AVD). It includes practical exercises for developing simple Android applications, such as a 'Hello World' app, a registration page, a login module, and a calculator app, detailing the necessary components and code snippets for each. Additionally, it explains the use of intents in Android for communication between app components.

Uploaded by

trisharanwagh1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Lab on Android Application Development Theory

The document provides a comprehensive guide for setting up the Java Development Kit (JDK), Android SDK, Eclipse IDE, and Android Development Tools (ADT) plugins, along with creating an Android Virtual Device (AVD). It includes practical exercises for developing simple Android applications, such as a 'Hello World' app, a registration page, a login module, and a calculator app, detailing the necessary components and code snippets for each. Additionally, it explains the use of intents in Android for communication between app components.

Uploaded by

trisharanwagh1
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Practical 1

Installation and setup of java development kit (JDK), setup android SDK, setup
eclipse IDE, setup android development tools (ADT) plugins, create android virtual
device

Installation and setup of java development kit (JDK)

Step 1: Download JDK from the Site

 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.

Step 2: Install the JDK exe 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.

 Click on the Close button once the installation has finished.

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.

Step 3: Check the Directory

 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.

 This is the directory structure for our example.

Step 4: Update the Environment Variables

 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.

For example: C:\> “C:\Program Files\Java\jdk-11.0\bin\javac” TestClass.java

 So to set these variables, first right-click on My PC and select Properties.

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.

 Click on the OK button to apply the changes.

Step 5: Verify the Java Installation

 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!

Setup android SDK

Install the SDK

Within Android Studio, you can install the Android 12 SDK as follows:

1. Click Tools > SDK Manager.

2. In the SDK Platforms tab, select Android 12.

3. In the SDK Tools tab, select Android SDK Build-Tools 31.

4. Click OK to install the SDK.

Setup eclipse IDE

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.

1. Install the JDK

2. Download and install the Eclipse for developing android application

3. Download and Install the android SDK

4. Intall the ADT plugin for eclipse

5. Configure the ADT plugin

6. Create the AVD

7. Create the hello android application

Setup android development tools (ADT) plugins

Step 1: Setup Java Development Kit (JDK)

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

Step 2: Configure Android SDK

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.

Step 3: Setup Eclipse IDE

Install the latest version of Eclipse. After successful installation, it should display a window like this:

Step 4: Setup Android Development Tools (ADT) Plugin

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.

Step 5: Create Android Virtual Device

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.

Create android virtual device

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).

Follow the below steps to install Android Virtual Device.

Step 1: Go to Tools > AVD Manager.

Step 2: Now click on Create Virtual Device

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 5: Click the finish button to complete the installation.

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

Create Android Application

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

Create Registra�on page to demonstra�on of Basic widgets available in android.

1. TextView

• Purpose: Displays text to the user.

• Usage: Used for labels, descrip�ons, or any text-based content.

<TextView

android:id="@+id/textView"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Hello, World!" />

2. EditText

• Purpose: A user-editable text field where the user can input data (e.g., username, password).

• Usage: Used for capturing user input in forms or search fields.

<EditText

android:id="@+id/editText"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Enter your name" />

3. Buton

• Purpose: A clickable buton that performs an ac�on when tapped.

• 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"

android:text="Click Me" />

4. ImageView

• Purpose: Displays images, such as logos, icons, or other graphical content.

• Usage: Commonly used for showing images or icons.

<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.

• Usage: O�en used for preference se�ngs or mul�ple-choice selec�ons.

<CheckBox

android:id="@+id/checkBox"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Accept Terms" />

6. RadioButon

• Purpose: Similar to CheckBox but works as part of a group where only one op�on can be selected at a �me.

• Usage: Commonly used for single-choice selec�ons within a group of op�ons.

<RadioButon

android:id="@+id/radioButon1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Op�on 1" />

7. Spinner

• Purpose: A drop-down menu for selec�ng one op�on from a list.

• 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.

• Usage: Common for adjus�ng values like volume, brightness, or progress.

<SeekBar
android:id="@+id/seekBar"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:max="100"

android:progress="50" />

9. ProgressBar

• Purpose: Displays the progress of a task.

• 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

Create sample application with login module.(Check username and password) On


successful login, Change TextView “Login Successful”. And on failing login, alert
user using Toast “Login fail”.

Text View Attributes

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.

Sr.No. Attribute & Description

1 android:id

This is the ID which uniquely identifies the control.

2 android:capitalize

If set, specifies that this TextView has a textual input method and should automatically
capitalize what the user types.

 Don't automatically capitalize anything - 0

 Capitalize the first word of each sentence - 1

 Capitalize the first letter of every word - 2

 Capitalize every character - 3

3 android:cursorVisible

Makes the cursor visible (the default) or invisible. Default is false.

4 android:editable

If set to true, specifies that this TextView has an input method.

5 android:fontFamily

Font family (named by string) for the text.

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

Hint text to display when the text is empty.

8 android:inputType

The type of data being placed in a text field. Phone, Date, Time, Number, Password etc.

9 android:maxHeight Makes the TextView be at most this many pixels tall.

10 android:maxWidth

Makes the TextView be at most this many pixels wide


Practical 5

Create an application for demonstration of Scroll view in android.

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.

Android uses HorizontalScrollView for horizontal ScrollView.

Let's implement simple example of vertical ScrollView.

Step 1: Create a new project

1. Click on File, then New => New Project.

2. Choose “Empty Activity” for the project template.

3. Select language as Java.

4. Select the minimum SDK as per your need.

Step 2: Modify strings.xml

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

Steps for Implementing form Validation in Android


Step 1: Create an empty activity project
 Create an empty activity Android Studio project. And select the programming language as JAVA.
 to know how to create an empty activity android studio project.
Step 2: Working with the activity_main.xml
 Here in this case for demonstration purposes, only four text fields are implemented those are,
First Name, Last Name, Email, and Password.
 Invoke the following code inside the activity_main.xml file.
Practical 7
Create an application for calculator.

Steps to Create a Calculator App in Android:

1. Create a new Android project in Android Studio.

2. Design the user interface (UI) in the activity_main.xml.

3. Write the logic for handling the calculations in the MainActivity.java.

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.

• Operations: The calculateResult() method performs the necessary arithmetic


operation based on the selected operator.

• Clear Button: Clears the input and resets everything to default.

 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.

• The C button clears the input.

Key Points :

• State Management: The calculator needs to keep track of the current input,
selected operator, and operands.

• Button Handling: Each button needs to perform the appropriate action,


whether it's adding a digit, setting an operator, or calculating the result.
Practical 8

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.

Types of Android Intents

There are two types of intents in android

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.

You might also like