Android Development Lab Manual 2024
Android Development Lab Manual 2024
LAB MANUAL
9
Design an android application for Menu. 15-10-2025
Create a user registration application that
10
stores the user details in a database table. 29-10-2025
Experiment Number 01
Experiment Title Installation of Android Studio
Objective To install and configure Android Studio IDE for Android application
development.
• Windows/Linux/macOS OS
Materials
• Android Studio installer
Conclusion
Android Studio setup is complete and system is ready for development.
Experiment Number 02
Experiment Title Development of Hello World Application
Introduction The Hello World program is the basic test for any programming
environment.
• Android Studio
Materials
• Emulator/Android Device
Analysis /
This verified that IDE setup and build system are correct.
Discussion
Step 1: activity_main.xml
This file defines the UI layout — one EditText for input, one Button, and one TextView for
Implementation output.
<EditText
android:id="@+id/etName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter your name"
android:textSize="18sp"
android:inputType="textPersonName" />
<Button
android:id="@+id/btnOk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK"
android:layout_marginTop="20dp" />
<TextView
android:id="@+id/tvResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textStyle="bold"
android:layout_marginTop="20dp"
android:textColor="@android:color/black" />
</LinearLayout>
Step 2: [Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
{ EditText etName;
Button btnOk;
TextView tvResult;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
etName = findViewById([Link]);
btnOk = findViewById([Link]);
tvResult = findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View view) {
String name = [Link]().toString().trim();
if (![Link]())
{ [Link]("Hello " + name +
"!");
} else {
[Link]("Please enter your name.");
}
}
});
}
}
OUTPUT
Hello Ankita!
Experiment 04
Number
Experiment Create a screen that has input boxes for User Name, Password, Address and Gender
Title (radio buttons for male and female), Age (numeric), Date of Birth (Date Picker), State
(Spinner) and a Submit button.
On clicking the submit button, print all the data below the Submit Button (use any
layout).
This layout contains all input fields and a TextView to show the output below the Submit
button.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp">
<RadioGroup
android:id="@+id/rgGender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/rbMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male" />
<RadioButton
android:id="@+id/rbFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female" />
</RadioGroup>
package [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
etName = findViewById([Link]);
etPassword = findViewById([Link]);
etAddress = findViewById([Link]);
etAge = findViewById([Link]);
etDob = findViewById([Link]);
rgGender = findViewById([Link]);
spinnerState = findViewById([Link]);
btnSubmit = findViewById([Link]);
tvResult = findViewById([Link]);
// Spinner Data
String[] states = {"Select State", "Madhya Pradesh", "Uttar Pradesh", "Maharashtra",
"Gujarat", "Rajasthan"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
[Link].simple_spinner_item, states);
[Link]([Link].simple_spinner_dropdown_item);
[Link](adapter);
// DatePicker
[Link](new [Link]() {
@Override
public void onClick(View v) {
final Calendar calendar = [Link]();
int year = [Link]([Link]);
int month = [Link]([Link]);
int day = [Link](Calendar.DAY_OF_MONTH);
[Link](result);
}
}
});
}
}
User Details:
Name: Ankita
Password: 12345
Address: Bhopal, MP
Gender: Female
Age: 22
DOB: 10/11/2003
State: Madhya Pradesh
Experiment 05
Number
Experiment Design an android application to create page using Intent and one Button and pass the
Title values from one Activity to second Activity.
Android app using Explicit Intent.
• MainActivity – Has a button and a text field to send data.
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:padding="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_marginBottom="10dp"/>
<EditText
android:id="@+id/editTextName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Type here"
android:padding="10dp"
android:background="@android:drawable/edit_text"/>
<Button
android:id="@+id/buttonSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"/>
</LinearLayout>
<LinearLayout xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:padding="20dp">
<TextView
android:id="@+id/textViewResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"/>
</LinearLayout>
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
EditText editTextName;
Button buttonSend;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
editTextName = findViewById([Link]);
buttonSend = findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
String name = [Link]().toString();
startActivity(intent);
}
});
}
}
save clrt+s
Step 5: Code for [Link]
package [Link];
import [Link];
import [Link];
import [Link];
{ TextView textViewResult;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_second);
textViewResult = findViewById([Link]);
<EditText
android:id="@+id/etPhone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter phone number"
android:inputType="phone"
android:textSize="18sp" />
<EditText
android:id="@+id/etMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter message"
android:inputType="textMultiLine"
android:lines="3"
android:layout_marginTop="15dp"
android:textSize="18sp" />
<Button
android:id="@+id/btnSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send SMS"
android:layout_marginTop="20dp" />
</LinearLayout>
Step 2: [Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import
[Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
etPhone = findViewById([Link]);
etMessage = findViewById([Link]);
btnSend = findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View view) {
String phone = [Link]().toString().trim();
String message = [Link]().toString().trim();
if ([Link]() || [Link]())
{ [Link]([Link], "Please enter phone and message",
Toast.LENGTH_SHORT).show();
} else {
// Create the SMS Intent
Intent intent = new Intent(Intent.ACTION_VIEW);
[Link]([Link]("[Link] + phone));
[Link]("sms_body", message);
To: 9876543210
Message: Hello, how are you?
Experiment 07
Number
Experiment
Title Create an android application using Fragments.
Implementation Step 1: activity_main.xml
This is the main layout that contains two buttons and a FrameLayout where
fragments will be loaded.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<Button
android:id="@+id/btnFragmentA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Fragment A" />
<Button
android:id="@+id/btnFragmentB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Fragment B"
android:layout_marginStart="20dp" />
</LinearLayout>
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="30dp" />
</LinearLayout>
Step 2: [Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
btnFragmentA = findViewById([Link]);
btnFragmentB = findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v)
{ loadFragment(new
FragmentA());
}
});
[Link](new [Link]() {
@Override
public void onClick(View v)
{ loadFragment(new
FragmentB());
}
});
}
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
TextView textView = new TextView(getActivity());
[Link]("Welcome to Fragment A");
[Link](24);
[Link](50, 50, 50, 50);
return textView;
}
}
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
TextView textView = new TextView(getActivity());
[Link]("Welcome to Fragment B");
[Link](24);
[Link](50, 50, 50, 50);
return textView;
}
}
Step 5: [Link]
<manifest xmlns:android="[Link]
package="[Link]">
<application
android:allowBackup="true"
android:label="Fragment Example"
android:supportsRtl="true"
android:theme="@style/[Link]">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]"/>
<category android:name="[Link]"/>
</intent-filter>
</activity>
</application>
</manifest>
OUTPUT
[ Show Fragment A ] [ Show Fragment B ]
-----------------------------------------
Welcome to Fragment A
Welcome to Fragment A
Welcome to Fragment B
Experiment 08
Number
Experiment
Title Design an android application using Radio buttons.
Step 1: activity_main.xml
Implementation
This file defines the UI layout — a RadioGroup with three RadioButtons, a Button, and a
TextView for output.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select your Gender:"
android:textSize="20sp"
android:layout_marginBottom="20dp" />
<RadioGroup
android:id="@+id/radioGroupGender"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="@+id/radioMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male" />
<RadioButton
android:id="@+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female" />
<RadioButton
android:id="@+id/radioOther"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Other" />
</RadioGroup>
<Button
android:id="@+id/btnSubmit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:layout_marginTop="20dp" />
<TextView
android:id="@+id/tvResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:layout_marginTop="30dp"
android:textStyle="bold" />
</LinearLayout>
Step 2: [Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
{ RadioGroup radioGroupGender;
Button btnSubmit;
TextView tvResult;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
radioGroupGender = findViewById([Link]);
btnSubmit = findViewById([Link]);
tvResult = findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
if (selectedId == -1) {
[Link]([Link], "Please select your gender",
Toast.LENGTH_SHORT).show();
} else {
RadioButton selectedRadioButton = findViewById(selectedId);
String selectedGender = [Link]().toString();
[Link]("Selected Gender: " + selectedGender);
}
}
});
}
}
Step 3: [Link]
<manifest xmlns:android="[Link]
package="[Link]">
<application
android:allowBackup="true"
android:label="Radio Button App"
android:supportsRtl="true"
android:theme="@style/[Link]">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
( ) Female
( ) Other
[ Submit ]
On clicking Submit:
Experiment 09
Number
Experiment
Title Design an android application for Menu.
Implementation Step 1: activity_main.xml
This layout just contains a simple TextView to display the selected menu item.
<TextView
android:id="@+id/tvMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Select an option from the menu"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="@android:color/black" />
</LinearLayout>
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
{ TextView tvMessage;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
tvMessage = findViewById([Link]);
}
case [Link].menu_settings:
[Link]("Settings selected");
[Link](this, "You selected Settings", Toast.LENGTH_SHORT).show();
return true;
case [Link].menu_about:
[Link]("About selected");
[Link](this, "You selected About", Toast.LENGTH_SHORT).show();
return true;
default:
return [Link](item);
}
}
}
Step 4: [Link]
<manifest xmlns:android="[Link]
package="[Link]">
<application
android:allowBackup="true"
android:label="Menu Example"
android:supportsRtl="true"
android:theme="@style/[Link]">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
When you tap the 3-dot menu (⋮) or Action Bar icons:
Home
Settings
About
This layout contains 3 EditText fields, one Button, and one TextView.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
android:gravity="center">
<EditText
android:id="@+id/etName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Name"
android:inputType="textPersonName"
android:textSize="18sp" />
<EditText
android:id="@+id/etEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Email"
android:inputType="textEmailAddress"
android:textSize="18sp"
android:layout_marginTop="10dp" />
<EditText
android:id="@+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Password"
android:inputType="textPassword"
android:textSize="18sp"
android:layout_marginTop="10dp" />
<Button
android:id="@+id/btnRegister"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Register"
android:layout_marginTop="20dp" />
<TextView
android:id="@+id/tvStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:textSize="18sp"
android:textColor="@android:color/black" />
</LinearLayout>
Step 2: [Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
etName = findViewById([Link]);
etEmail = findViewById([Link]);
etPassword = findViewById([Link]);
btnRegister =
findViewById([Link]); tvStatus =
findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View view) {
String name = [Link]().toString();
String email = [Link]().toString();
String password = [Link]().toString();
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Override
public void onCreate(SQLiteDatabase db) {
String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + "("
+ COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
+ COL_NAME + " TEXT,"
+ COL_EMAIL + " TEXT,"
+ COL_PASSWORD + " TEXT)";
[Link](CREATE_TABLE);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion)
{ [Link]("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
<manifest xmlns:android="[Link]
package="[Link]">
<application
android:allowBackup="true"
android:label="User Registration"
android:supportsRtl="true"
android:theme="@style/[Link]">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>