0% found this document useful (0 votes)
9 views48 pages

MA Lab Manual

The document is a lab manual for the Mobile Application Laboratory course at Muthayammal Engineering College, detailing the institution's vision, mission, and educational objectives. It outlines the program's educational objectives, outcomes, and specific outcomes, along with laboratory safety guidelines and a list of experiments to be conducted. The manual includes step-by-step procedures for various Android development tasks, such as creating virtual devices, implementing menus, and running applications in the Android emulator.

Uploaded by

dharsanimv
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)
9 views48 pages

MA Lab Manual

The document is a lab manual for the Mobile Application Laboratory course at Muthayammal Engineering College, detailing the institution's vision, mission, and educational objectives. It outlines the program's educational objectives, outcomes, and specific outcomes, along with laboratory safety guidelines and a list of experiments to be conducted. The manual includes step-by-step procedures for various Android development tasks, such as creating virtual devices, implementing menus, and running applications in the Android emulator.

Uploaded by

dharsanimv
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/ 48

MUTHAYAMMAL ENGINEERING COLLEGE

(An Autonomous Institution)


(Approved by AICTE, New Delhi, Accredited by NAAC & Affiliated to Anna
University)
Rasipuram - 637 408, Namakkal Dist., Tamil Nadu

DEPARTMENT OF INFORMATION TECHNOLOGY

LAB MANUAL

21ITC14 MOBILE APPLICATION LABORATORY

PREPARED BY
Mr.T.Manivel, M.Tech.,(Ph.D)., Assistant Professor, Department of IT

1
MEC / IT / MOBILE APPLICATION LABORATORY
Institution Vision and Mission
Vision

To be a Centre of Excellence in Engineering, Technology and Management on par with


International Standards.

Mission
 To prepare the students with high professional skills and ethical values
 To impart knowledge through best practices
 To instil a spirit of innovation through Training, Research and Development
 To undertake continuous assessment and remedial measures
 To achieve academic excellence through intellectual, emotional and social stimulation

Department Vision and Mission

Vision

Excellence in Information Technology by offering quality technical education providing to


research and development.

Mission
M1: Equip the students with high quality education and carrying out research in emerging
technologies in Information Technology

M2: Expose the students, faculty and staff to a globally competitive learning experience

M3: Motivate the students to realize the responsibility of being professionally proficient
information technocrats to serve the society by inculcating Ethical and Environmental aspects.

2
MEC / IT / MOBILE APPLICATION LABORATORY
Program Educational Objectives (PEOs):

PEO1: Graduates will have successful career in IT and related industries or pursue higher
education and research or evolve as entrepreneurs.

PEO2: Graduates will have the ability and attitude to adapt emerging technological changes
in Information Technology.

PEO3: Graduates will excel as socially committed engineers with high ethical values,
leadership qualities and empathy for the needs of society.

Program Outcomes (POs):

PO1 Engineering Knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering
problems

PO2 Problem Analysis: Identify, formulate, review research literature, and analyze
complex engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.

PO3 Design / Development Solutions: Design solutions for complex engineering problems
and design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.

PO4 Conduct Investigations of Complex Problems: Use research-based knowledge and


research methods including design of experiments, analysis and interpretation of data, and
synthesis of the information to provide valid conclusions

PO5 Modern Tool Usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex
engineering activities with an understanding of the limitations.

PO6 The Engineer and Society: Apply reasoning informed by the contextual knowledge
to assess societal, health, safety, legal and cultural issues and the consequent

3
MEC / IT / MOBILE APPLICATION LABORATORY
responsibilities relevant to the professional engineering practice.

PO7 Environment and Sustainability: Understand the impact of the professional


engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.

PO8 Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the engineering practice.

PO9 Individual and Team work: Function effectively as an individual, and as a member
or leader in diverse teams, and in multidisciplinary settings.

PO10 Communication: Communicate effectively on complex engineering activities with the


engineering community and with society at large, such as, being able to comprehend and
write effective reports and design documentation, make effective presentations, and give and
receive clear instructions.

PO11 Project Management and Finance Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.

PO12 Lifelong Learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological change.

Program Specific Outcomes (PSOs):


PSO1: Excel in software development including mobile technologies to solve complex
computation task with soft skills.

PSO2: Apply appreciable knowledge of IoT, Cloud Computing and Cyber Security to develop
reliable IT solutions.

PSO3: Exhibit proficiency in Artificial Intelligence and Big Data Analytics for providing
solutions to real world problems in Industry and Research establishments

4
MEC / IT / MOBILE APPLICATION LABORATORY
Do’s and Dont’s in the Laboratory:

DO’s

 Know the location of the fire extinguisher and the first aid box and how to use them incase
of an emergency.

 Read and understand how to carry out an activity thoroughly before coming to the
laboratory.

 Report fires or accidents to your lecturer/laboratory technician immediately.

 Report any broken plugs or exposed electrical wires to your lecturer/laboratory


technician immediately.

 Shut down your computer, when you leave from the laboratory.

DON’Ts

 Do not eat or drink in the laboratory.

 Avoid stepping on electrical wires or any other computer cables.

 Do not open the system unit casing or monitor casing 

 Do not insert metal objects such as clips, pins and needles into the computer casings.

 Do not remove anything from the computer laboratory without permission.

 Do not touch, connect or disconnect any plug or cable without your lecturer/laboratory
technician’s permission.

 Do not misbehave in the computer laboratory.

5
MEC / IT / MOBILE APPLICATION LABORATORY
LIST OF PROGRAMS

1. Test the android development environment by performing the following operations.


a. Add the sample application to a project in Android studio.
b. Create an Android Virtual Device (AVD) for sample project.
c. Create a launch configuration for sample project.
d. Run a sample application in Android Emulator.
2. Develop a program which will implement Sub menu in android application.
3. Develop a program to implement Context menu (Floating List of Menu Items) in
android application.
4. Develop a program to implement Email service by using Relative Layout Views with
different attributes.
5. Develop GMaps application by using Linear Layout Views with different attributes.
6. Develop a program to implement a Custom Button and handle the displayed message
on button press.
7. Develop a program to implement the Table layout in View Group that displays child
View elements in rows and columns.
8. Develop a program to implement the List View in android application.
9. Develop a program to show how to use Date picker control of ADK in android
applications
10. Develop a program to insert, delete, display, and update the employee details using
Android SQLite.
11. Design and develop a program to create sign-up and sign-in pages and maintain the user
details with SQLite
Mini project: Develop the following applications using Android.
a. Alarm b. Calculator c. Weather application d. Video Player

6
MEC / IT / MOBILE APPLICATION LABORATORY
Index

S.No Name of the Experiment Page No.

MEC / IT / MOBILE APPLICATION LABORATORY 11


EXPERIMENT NO: 1

a) Adding a Sample Application to a Project in Android Studio

Aim:
The aim of this lab is to guide you through the process of adding a sample application to a project in Android
Studio. By the end of this exercise, you should be familiar with integrating external code into your Android
Studio project.

Procedure:
1. Open Android Studio:
- Launch Android Studio on your computer.
2. Create a New Project:
- Start a new Android Studio project or open an existing project where you want to add the sample application.
3. Download the Sample Application:
- Visit the official repository or website from which you want to download the sample application.
- Download the source code as a zip file and extract it to a known location on your computer.
4. Open Your Project in Android Studio:
- Navigate to Android Studio and open the project where you want to incorporate the sample application.
5. Import the Sample Application:
- In Android Studio, go to `File > New > Import Module`.
- Choose the directory where you extracted the sample application.
- Follow the on-screen instructions to import the module.
6. Configure Dependencies:
- Open the `build.gradle` file of your main project.
- Add the following line in the `dependencies` block to include the sample application module:
Gradle
implementation project(':sample_module_name')
7. Program Integration:
- Navigate to the code where you want to use functionalities from the sample application.
- Import necessary classes or modules from the sample application in your code.
8. Build and Run:
- Click on the "Run" button in Android Studio.
- Ensure your project builds successfully without any errors.

Output:

MEC / IT / MOBILE APPLICATION LABORATORY 12


Result:
Your Android Studio project now successfully incorporates the sample application, allowing you to
leverage its functionalities in your own project

MEC / IT / MOBILE APPLICATION LABORATORY 13


EXPERIMENT NO: 1

b) Creating an Android Virtual Device (AVD) for Sample Project

Aim:

The aim of this lab is to guide you through the process of creating an Android Virtual Device (AVD) for a sample
project. This is a crucial step in Android app development as it allows you to test your applications on different
virtual devices before deploying them to real devices.

Procedure:

1. Open Android Studio:


- Launch Android Studio on your development machine.
2. Open or Create a Project:
- Open an existing Android project or create a new one. Ensure that the project is loaded successfully.
3. Navigate to AVD Manager:
- In Android Studio, go to the "Tools" menu.
- Select "AVD Manager" from the dropdown.
4. Create a New Virtual Device:
- In the AVD Manager, click on "Create Virtual Device."
- Choose the hardware profile that matches the characteristics you want for your virtual device (e.g., Pixel 4).
- Click "Next."
5. Select a System Image:
- Choose a system image for the virtual device. It's recommended to download the latest image for the
desired Android version.
- Click "Next."
6. Configure Virtual Device:
- Set the device orientation, scale, and other parameters according to your project requirements.
- Click "Next."
7. Verify Configuration:
- Review the configuration details of the virtual device.
- Click "Finish" to create the virtual device.

MEC / IT / MOBILE APPLICATION LABORATORY 14


Output:

Result:

After completing this lab, you will have a functional Android Virtual Device that can be used for testing and
debugging your Android applications.

MEC / IT / MOBILE APPLICATION LABORATORY 15


EXPERIMENT NO: 1

c) Creating a Launch Configuration for a Sample


Project

Aim:

The aim of this lab is to guide you through the process of creating a launch configuration for a sample
project in Android Studio. Launch configurations are essential for running and debugging applications
efficiently.

Procedure:

1. Open Android Studio:


Launch Android Studio on your computer and ensure that the sample project is loaded.
2. Navigate to Run/Debug Configurations:
- Locate and click on the dropdown menu next to the Run/Debug configurations toolbar.
- Select "Edit Configurations..." from the dropdown list.
3. Create a New Configuration:
- In the Run/Debug Configurations dialog, click the "+" button in the top left corner to add a new
configuration.
- Choose the appropriate configuration type for your project, typically "Android App" for Android
applications.
4. Configure General Settings:
- Provide a meaningful name for your configuration in the "Name" field.
- Select the desired module from the "Module" dropdown menu.
5. Specify Deployment Target:
- In the "Deployment Target Options," choose the target device or emulator where you want to run the
application.
6. Configure Build and Install Options:
- Customize build and install options as needed, such as selecting the installation options and
configuring APK installation.
7. Set Launch Options:
- Define launch options, such as the activity to start or the intent to use when launching the
application.
8. Configure Miscellaneous Options:
- Adjust any additional settings under the "Miscellaneous" tab, if necessary.

MEC / IT / MOBILE APPLICATION LABORATORY


16
Output:

MEC / IT / MOBILE APPLICATION LABORATORY


17
Result:

Upon completing the lab, you should be able to run and debug your Android application efficiently
using the configured launch configuration. This skill is crucial for effective development and testing in
Android Studio.

MEC / IT / MOBILE APPLICATION LABORATORY


18
EXPERIMENT NO: 1

d) Running a Sample Application in


Android Emulator

Aim:

The aim of this lab is to guide you through the process of running a sample Android application in the
Android Emulator. This exercise will help you familiarize yourself with the Android development
environment and understand the basics of deploying applications on an emulator.

Procedure:

1. Setup Android Studio:


- Ensure that you have Android Studio installed on your machine.
- Open Android Studio and make sure the necessary SDKs are downloaded.
2. Create or Import a Sample Project:
- Create a new Android project or import an existing sample project from the official Android
developer website.
- Follow the instructions in Android Studio to set up the project.
3. Configure Virtual Device (Emulator):
- Open the AVD Manager (Android Virtual Device Manager) from the toolbar or the menu.
- Create a new Virtual Device by specifying the device type, system image, and other configurations.
- Start the emulator by clicking on the "Play" button next to the created virtual device.
4. Run the Application:
- Open the project in Android Studio.
- Select the virtual device you created in the toolbar.
- Click on the "Run" button (green triangle) or use the shortcut (Shift + F10) to deploy the application
on the emulator.
5. Observe the Output:
- Monitor the Android Emulator as the application is launched.
- Observe the application's behavior in the emulator.
- Check the Android Studio Run tab for any error messages or logs.

Output:

MEC / IT / MOBILE APPLICATION LABORATORY 19


Result:

Upon successful completion of the above steps, you should be able to run a sample Android application
in the Android Emulator without encountering any major issues. The emulator will display the output of
the application, and you'll gain a practical understanding of the deployment process.

MEC / IT / MOBILE APPLICATION LABORATORY 20


EXPERIMENT NO: 2

Implementing Submenu in Android


Application

Aim:

The aim of this lab is to develop an Android application that implements a submenu. This will enhance
your understanding of creating interactive and user-friendly interfaces using Android Studio.

Procedure:

1. Setting up the Project:


- Open Android Studio and create a new Android project.
- Choose an appropriate project template and configure the project settings.
2. Designing the Main Layout:
- Open the main layout file (usually `activity_main.xml`) in the "res/layout" folder.
- Design the main interface with necessary components, like buttons, text views, etc.
- Reserve a space for the submenu.
3. Implementing the Submenu:
- Create a new XML layout file for the submenu (e.g., `submenu_layout.xml`).
- Define the submenu items using appropriate UI components (e.g., buttons, text views).
- Ensure visibility of the submenu is initially set to "GONE" in the main layout.
4. Coding the Main Activity:
- Open the main activity file (usually `MainActivity.java`).
- Define variables for the main interface components and the submenu.
- Initialize these variables in the `onCreate` method.
- Implement click listeners for the main interface components to toggle the visibility of the submenu.

> java
// Example code snippet for initializing variables and handling click events
Button mainButton = findViewById(R.id.mainButton);
LinearLayout submenuLayout = findViewById(R.id.submenuLayout);

mainButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Toggle visibility of the submenu
if (submenuLayout.getVisibility() == View.VISIBLE) {
submenuLayout.setVisibility(View.GONE);
} else {
submenuLayout.setVisibility(View.VISIBLE);
}
}
});

5. Adding Functionality to Submenu Items:


- Implement functionality for each submenu item.
- You can link each item to a specific activity, fragment, or feature.
6. Testing:
- Run the application on an emulator or physical device.
MEC / IT / MOBILE APPLICATION LABORATORY 21
- Test the functionality of the submenu by interacting with the main interface and submenu items.

Program:

> java
// Import necessary packages
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class MainActivity extends AppCompatActivity {

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

// Initialize main interface components and submenu


Button mainButton = findViewById(R.id.mainButton);
LinearLayout submenuLayout = findViewById(R.id.submenuLayout);

// Set click listener for the main button to toggle submenu visibility
mainButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (submenuLayout.getVisibility() == View.VISIBLE) {
submenuLayout.setVisibility(View.GONE);
} else {
submenuLayout.setVisibility(View.VISIBLE);
}
}
});

// Add functionality for submenu items (you can customize this part)
Button submenuItem1 = findViewById(R.id.submenuItem1);
submenuItem1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Implement functionality for submenu item 1
}
});

// Repeat the above pattern for other submenu items


}
}

MEC / IT / MOBILE APPLICATION LABORATORY 22


Output:

Result:

Upon successful completion of this lab, you will have gained hands-on experience in creating an Android
application that incorporates a submenu, improving your skills in Android app development.

MEC / IT / MOBILE APPLICATION LABORATORY 23


EXPERIMENT NO: 3

Implementing Context Menu in Android Application

Aim:

To develop a program that implements a Context Menu, which is a floating list of menu items, in an
Android application.

Procedure:

1. Setup:
- Open Android Studio and create a new Android project.
- Choose an appropriate project template and set the project name.
2. Design Layout:
- Open the XML layout file (`activity_main.xml`) and design the layout where the Context Menu will
be implemented.
3. Implement Context Menu in Java Code:
- Open the Java file corresponding to the main activity (`MainActivity.java`).
- Declare variables and find the View that will trigger the Context Menu.
- Override the `onCreateContextMenu` method to define the menu items.
- Override the `onContextItemSelected` method to handle item selection.

> java
// Sample code snippet
public class MainActivity extends AppCompatActivity {
// Declare variables

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

// Find the View


View myView = findViewById(R.id.myView);

// Register the View for the Context Menu


registerForContextMenu(myView);
}

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo
menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
// Define menu items
MEC / IT / MOBILE APPLICATION LABORATORY 24
menu.setHeaderTitle("Context Menu");
menu.add(Menu.NONE, 1, Menu.NONE, "Item 1");
menu.add(Menu.NONE, 2, Menu.NONE, "Item 2");
// Add more items as needed
}

@Override
public boolean onContextItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case 1:
// Implement action for Item 1
return true;
case 2:
// Implement action for Item 2
return true;
// Handle more items as needed
default:
return super.onContextItemSelected(item);
}
}
}
4. Run the Application:
- Connect a device or use an emulator to run the application.
- Observe the Context Menu behavior when triggering the specified View.

Output:

Result:
Upon running the application, the user should be able to trigger a Context Menu by performing a long press
on the designated View. The menu should display the defined items, and selecting an item should execute
the corresponding action.
MEC / IT / MOBILE APPLICATION LABORATORY 25
EXPERIMENT NO: 4

Developing an Email Service Program using Relative Layout Views

Aim:

The aim of this lab is to develop a simple Android program implementing an email service using Relative
Layout views with different attributes.

Procedure:

1. Setup:
- Open Android Studio and create a new Android Studio project.
- Choose an appropriate project name and set up the basic project parameters.
2. Design the User Interface:
- Open the `activity_main.xml` file.
- Use Relative Layout as the root layout.
- Add necessary views such as EditText for email input, TextView for labels, Button for sending
emails, etc.
- Apply different attributes to the Relative Layout views, adjusting positioning and styling.
3. Implement the Email Service Logic:
- Open the `MainActivity.java` file.
- Implement the necessary logic for sending emails. You can use Android's Intent system to launch the
email client.
- Handle user input validation to ensure a valid email address is entered.

4. Code Example:

> java
// Inside MainActivity.java
public class MainActivity extends AppCompatActivity {

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

Button sendButton = findViewById(R.id.sendButton);


EditText emailEditText = findViewById(R.id.emailEditText);

sendButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String emailAddress = emailEditText.getText().toString();

MEC / IT / MOBILE APPLICATION LABORATORY 26


// Validate the email address
if (!TextUtils.isEmpty(emailAddress) &&
android.util.Patterns.EMAIL_ADDRESS.matcher(emailAddress).matches()) {
// Use Intent to launch email client
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.setData(Uri.parse("mailto:" + emailAddress));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Body of the email");
startActivity(emailIntent);
} else {
// Display an error message for invalid email address
Toast.makeText(MainActivity.this, "Invalid email address",
Toast.LENGTH_SHORT).show();
}
}
});
}
}

5. Run the Program:


- Build and run the program on an emulator or a physical Android device.
- Test the email service functionality by entering a valid email address and clicking the send button.

Output:

Result:

Upon successful implementation, you should be able to demonstrate a working email service program with
a well-designed user interface using Relative Layout views with different attributes.

MEC / IT / MOBILE APPLICATION LABORATORY 27


EXPERIMENT NO: 5

Developing GMaps Application Using Linear Layout Views with


Different Attributes
Aim:

The aim of this lab is to create a Google Maps (GMaps) application using Android Studio, implementing
the user interface with Linear Layout views and exploring various attributes to enhance the layout.

Procedure:

1. Setup:
- Launch Android Studio and create a new Android Studio project with an empty activity.
- Set the project name as "GMapsApp" and choose an appropriate package name.
- Ensure you have the necessary dependencies for Google Maps in your `build.gradle` file.
2. Designing Layout with Linear Layout:
- Open the `activity_main.xml` file in the `res/layout` directory.
- Replace the default layout with a Linear Layout.
- Experiment with different attributes of the Linear Layout such as `orientation`, `gravity`, and
`layout_weight` to achieve the desired design.
3. Integrate Google Maps:
- In the `activity_main.xml`, add a `fragment` element to hold the Google Maps.
- Obtain a Google Maps API key from the Google Cloud Console and include it in the
`AndroidManifest.xml`.
- Configure the Google Maps fragment to use the obtained API key.
4. Customize Map View:
- Use the Google Maps API to customize the map view.
- Implement features such as zoom controls, map type, and markers on the map.
5. Testing:
- Run the application on an emulator or a physical device to test the functionality.
- Ensure that the Google Maps loads correctly and responds to user interactions.

Program:

Below is a simplified example of the `activity_main.xml` layout file:

> xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center">

<!-- Your other UI components can be added here -->

MEC / IT / MOBILE APPLICATION LABORATORY 28


<fragment
android:id="@+id/mapFragment"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />

<!-- Your other UI components can be added here -->

</LinearLayout>

Output:

Result:

Upon successful completion of this lab, you will have developed a GMaps application using Linear
Layout views with various attributes. The application will provide a customized map interface and serve
as a foundation for further enhancements and features.

MEC / IT / MOBILE APPLICATION LABORATORY 29


EXPERIMENT NO: 6

Implementing a Custom Button Program and handle the displayed


message on button press
Aim:

The aim of this lab is to develop a program in Android Studio to implement a custom button and handle
the displayed message on button press.

Procedure:

1. Setting up Android Studio:


- Ensure Android Studio is installed on your machine.
- Create a new Android Studio project.
2. Designing the Custom Button:
- Open the `activity_main.xml` file in the `res/layout` directory.
- Add a `Button` element and customize its attributes to make it visually distinct as a custom button.
3. Creating Button Handler:
- In the `MainActivity.java` file, create a method to handle the button press event. For example:
> java
public void onCustomButtonClick(View view) {
// Code to handle button press
}

- Ensure that this method is declared in the XML layout file as the `onClick` attribute for the custom
button.
4. Custom Button Implementation:
- Create a custom button class by extending the `Button` class or using existing components to
create a custom look.
- Implement any additional functionalities or animations for the custom button.
5. Linking Custom Button with Handler:
- In the `onCreate` method of `MainActivity`, find the custom button by its ID and set its
`OnClickListener` to the method created in step 3.
6. Displaying Message:
- Inside the `onCustomButtonClick` method, add code to display a message. For example:
> java
Toast.makeText(getApplicationContext(), "Custom Button Pressed!",
Toast.LENGTH_SHORT).show();

7. Testing:
- Run the application on an emulator or a physical device.
- Press the custom button and verify that the message is displayed as expected.

30
MEC / IT / MOBILE APPLICATION LABORATORY
Output:

Result:

The result of this lab is a functional Android application that demonstrates the implementation of a
custom button and the handling of the displayed message upon button press.

31
MEC / IT / MOBILE APPLICATION LABORATORY
EXPERIMENT NO: 7

Table Layout Implementation in Android in view group that


displays child view elements in rows and columns

Aim:

The aim of this lab is to develop an Android program that implements a table layout in a view group.
The program should display child view elements in rows and columns, creating an organized and
visually appealing interface.

Procedure:

1. Setting up the Project:


- Open Android Studio and create a new Android project.
- Choose an appropriate project template and set the project name.
- Configure the project with the desired package name and save location.
2. Designing the Layout:
- Open the `activity_main.xml` file in the `res/layout` folder.
- Use the `<TableLayout>` and `<TableRow>` elements to define the table structure.
- Add child view elements (e.g., TextView, ImageView) within the rows to represent the table cells.
3. Configuring Table Layout Parameters:
- Set appropriate layout parameters for the `<TableLayout>` and `<TableRow>` elements to control
the arrangement of child views.
- Experiment with attributes such as `layout_width`, `layout_height`, and `layout_weight` to achieve
the desired layout.
4. Populating Table Cells:
- In the `MainActivity.java` file, access the `<TableLayout>` element using `findViewById`.
- Use Java code to dynamically add child views to the rows within the table.
- You can create views programmatically or reference existing views from the layout.
5. Running the Program:
- Build and run the Android application on an emulator or physical device.
- Observe the table layout with child views arranged in rows and columns.

Program :

> java
// MainActivity.java

import android.os.Bundle;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

@Override
32
MEC / IT / MOBILE APPLICATION LABORATORY
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Access the TableLayout element


TableLayout tableLayout = findViewById(R.id.tableLayout);

// Example: Dynamically add TextViews to a TableRow


for (int i = 0; i < 3; i++) {
TableRow tableRow = new TableRow(this);

TextView textView1 = new TextView(this);


textView1.setText("Row " + (i + 1) + ", Col 1");
tableRow.addView(textView1);

TextView textView2 = new TextView(this);


textView2.setText("Row " + (i + 1) + ", Col 2");
tableRow.addView(textView2);

// Add the TableRow to the TableLayout


tableLayout.addView(tableRow);
}
}
}

Output:

Result:

The successful execution of the program will demonstrate the effective implementation of a table layout
in an Android view group, providing a clear structure for organizing and displaying child view elements.

33
MEC / IT / MOBILE APPLICATION LABORATORY
EXPERIMENT NO: 8

Implementing List View in Android Application

Aim:

The aim of this lab is to develop a program that implements a List View in an Android application. List
View is a fundamental UI component that displays a scrollable list of items, providing an efficient way
to present a set of data to the user.

Procedure:

1. Create a New Android Project:


- Open Android Studio and create a new Android project.
- Choose an appropriate project template and configure the project settings.

2. Design the Layout:


- Open the XML layout file (`activity_main.xml`) and define the layout for your activity.
- Include a `ListView` element to display the list of items.

3. Define Data Source:


- Create a data source (e.g., an array or a list) to hold the items you want to display in the List View.

4. Create an Adapter:
- Implement a custom adapter class to bind the data source to the List View.
- Override methods like `getView()` to customize the appearance of each list item.

5. Initialize List View:


- In the main activity (`MainActivity.java`), initialize the List View by finding its reference using
`findViewById()`.

6. Set Adapter to List View:


- Set the custom adapter to the List View using the `setAdapter()` method.

7. Handle Item Clicks (Optional):


- Implement an `OnItemClickListener` to respond to user clicks on list items.
- Define actions to be performed when a list item is clicked.

8. Run the Application:


- Build and run the application on an emulator or a physical device.

34
MEC / IT / MOBILE APPLICATION LABORATORY
Program:

> java
// MainActivity.java

import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

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

// Step 5: Initialize List View


ListView listView = findViewById(R.id.listView);

// Step 3: Define Data Source


String[] data = {"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"};

// Step 4: Create Adapter


ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,
data);

// Step 6: Set Adapter to List View


listView.setAdapter(adapter);

// Step 7: Handle Item Clicks (Optional)


listView.setOnItemClickListener((parent, view, position, id) -> {
// Handle item click here
});
}
}

35
MEC / IT / MOBILE APPLICATION LABORATORY
Output:

Result:

The developed Android application successfully implements a List View, providing a user-friendly
display of the specified data.

36
MEC / IT / MOBILE APPLICATION LABORATORY
EXPERIMENT NO: 9

Show how to Use Date Picker Control of ADK in Android


Application
Aim:

The aim of this lab is to develop a program demonstrating the implementation of a date picker control
in an Android application using the Android Development Kit (ADK). Participants will learn how to
integrate and utilize the date picker control to enhance user interaction with date selection in their
Android apps.

Procedure:

1. Setting Up the Project:


- Open Android Studio and create a new Android project.
- Set up the project with an appropriate name, package, and location.
- Choose an empty activity for the project.
2. Designing the Layout:
- Open the `activity_main.xml` file in the `res/layout` folder.
- Drag and drop a `DatePicker` widget onto the layout.
- Customize the layout as needed.
3. Implementing Date Picker in Java Code:
- Open the `MainActivity.java` file.
- Declare a `DatePicker` object in the class.
- Initialize the `DatePicker` in the `onCreate` method.
- Set listeners to handle date selection events.
4. Handling Date Selection Events:
- Implement the `DatePicker.OnDateChangedListener` interface.
- Override the `onDateChanged` method to capture the selected date.
- Display the selected date using a Toast message or update a TextView.
5. Testing the Application:
- Run the application on an Android emulator or physical device.
- Interact with the date picker to select different dates.
- Verify that the selected date is correctly displayed.

Program:

> java
// MainActivity.java
import android.app.Activity;
import android.os.Bundle;
import android.widget.DatePicker;
import android.widget.Toast;

public class MainActivity extends Activity implements DatePicker.OnDateChangedListener {


37
MEC / IT / MOBILE APPLICATION LABORATORY
private DatePicker datePicker;

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

datePicker = findViewById(R.id.datePicker);
datePicker.init(
datePicker.getYear(),
datePicker.getMonth(),
datePicker.getDayOfMonth(),
this
);
}

@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
String selectedDate = dayOfMonth + "/" + (monthOfYear + 1) + "/" + year;
Toast.makeText(getApplicationContext(), "Selected Date: " + selectedDate,
Toast.LENGTH_SHORT).show();
}
}

Output:

Result:

Upon completion of this lab, participants will have gained hands-on experience in integrating and
utilizing the date picker control in an Android application using ADK. They will be able to enhance the
user experience by allowing users to easily select dates within their apps.

38
MEC / IT / MOBILE APPLICATION LABORATORY
EXPERIMENT NO: 10

Android SQLite Employee Management Program

Aim:

The aim of this lab is to develop an Android application using SQLite to manage employee details. The
program should allow users to insert, delete, display, and update employee information.

Procedure:

1. Setting up the Android Project.


a. Open Android Studio and create a new Android project.
b. Choose an appropriate project name and set the minimum API level.
c. Select an Empty Activity template and proceed.
2. Designing the User Interface:
a. Open the `activity_main.xml` file.
b. Design the layout to include input fields for employee details and buttons for each operation
(insert, delete, display, update).
c. Ensure proper UI components for a good user experience.
3. Creating a Database Helper Class:
a. Create a class named `DatabaseHelper` that extends `SQLiteOpenHelper`.
b. Implement methods to create and upgrade the database.
c. Define constants for database name, table name, and column names.
4. Defining the Employee Model:
a. Create an `Employee` class to represent the structure of employee details.
b. Include fields such as employee ID, name, designation, etc.
c. Generate getters and setters for the fields.
5. Implementing Database Operations:
a. In the `DatabaseHelper` class, implement methods for inserting, deleting, updating, and querying
employee details.
b. Use SQL queries to perform these operations on the SQLite database.
6. Integrating Database Operations with UI:
a. In the main activity (`MainActivity.java`), initialize the `DatabaseHelper` class.
b. Implement onClickListeners for each button to trigger the respective database operations.
7. Displaying Results:
a. Implement a mechanism to display the results of operations, such as showing a Toast message or
updating a TextView.
b. Handle errors gracefully and provide informative messages to the user.
8. Testing:
a. Run the application on an emulator or a physical Android device.
b. Test each operation (insert, delete, display, update) to ensure proper functionality.
c. Debug and fix any issues that may arise.

39
MEC / IT / MOBILE APPLICATION LABORATORY
Output:

Result:

The program should effectively insert, delete, display, and update employee details, providing a
seamless user experience.

40
MEC / IT / MOBILE APPLICATION LABORATORY
EXPERIMENT NO: 11

a.Developing Signup and Signin Pages in Alarm Application

Aim:

The aim of this lab is to design and implement signup and signin pages for an Alarm Application using
Android Studio. This involves creating user interfaces for user registration and authentication.

Procedure:

1. Project Setup:
- Open Android Studio and create a new Android Project.
- Choose an appropriate project name and select the Empty Activity template.
- Set the language to Java.

2. Layout Design:
- Design the signup and signin screens using XML in the `res/layout` folder.
- Use `EditText` for input fields, `Button` for action triggers, and any other necessary components.
- Consider adding appropriate constraints and styles.

3. Activity Implementation:
- Create Java classes for SignupActivity and SigninActivity.
- Link the XML layouts to the corresponding activities using `setContentView()` in the `onCreate`
method.
- Implement basic functionality for each activity, such as handling button clicks.

4. User Authentication:
- Utilize Firebase Authentication or any preferred authentication library.
- Set up the necessary configurations for the chosen authentication method.
- Implement user registration and login functionality in the respective activities.

5. Connect Activities:
- Implement navigation between the signup and signin activities.
- Use `Intent` to move between activities when signup is successful or when the user wants to
switch between signup and signin.

6. Testing:
- Run the application on an emulator or a physical device.
- Test the signup and signin functionalities to ensure a smooth user experience.
- Verify that user data is being captured and stored securely.

Program:

Below is a simplified example of the Java code for the Signup Activity:

41
MEC / IT / MOBILE APPLICATION LABORATORY
>java
public class SignupActivity extends AppCompatActivity {

private EditText etUsername, etEmail, etPassword;


private Button btnSignup;

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

etUsername = findViewById(R.id.editTextUsername);
etEmail = findViewById(R.id.editTextEmail);
etPassword = findViewById(R.id.editTextPassword);
btnSignup = findViewById(R.id.buttonSignup);

btnSignup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Implement signup logic here
}
});
}
}

Output:

42
MEC / IT / MOBILE APPLICATION LABORATORY
Result:
Upon successful implementation, the application should provide users with a seamless experience for
signing up and signing in. Users' credentials should be securely stored and authenticated.

43
MEC / IT / MOBILE APPLICATION LABORATORY
b.Developing Signup and Signin Pages in Calculator Application

Aim:

The aim of this lab is to design and implement signup and signin pages for a calculator application using
Android Studio. This will involve creating user interfaces for both signup and signin, implementing
functionality for user authentication, and integrating these pages into the calculator application.

Procedure:

1. Setting up the Project:


- Open Android Studio and create a new Android project named "CalculatorApp."
- Choose an Empty Activity template.

2. Designing Signup Page:


- Create a new XML layout for the signup page.
- Design the layout with necessary components such as EditText for username and password,
buttons for signup, etc.
- Use appropriate XML attributes for styling and positioning.

3. Implementing Signup Functionality:


- In the associated Java file, handle user input validation for the signup page.
- Use Firebase Authentication or other authentication libraries to implement user registration
securely.
- Ensure proper error handling and feedback to the user.

4. Designing Signin Page:


- Create a new XML layout for the signin page.
- Design the layout with EditText for username and password, buttons for signin, etc.
- Apply consistent styling with the signup page.

5. Implementing Signin Functionality:


- In the Java file, handle user input validation for the signin page.
- Use the authentication library to verify user credentials.
- Provide appropriate feedback to the user, indicating successful signin or any authentication errors.

6. Integrating with Calculator Application:


- Create a seamless integration by adding navigation links between the signup, signin, and the main
calculator pages.
- Use Intent or other navigation components to switch between activities.

7. Testing:
- Test the signup and signin functionality thoroughly.

44
MEC / IT / MOBILE APPLICATION LABORATORY
- Ensure that user data is securely stored and retrieved during authentication.
- Test the integration with the calculator application to verify a smooth transition between
authentication and calculator functionalities.

Program:

Below is a simplified example of the Java code for the Signup Activity. Repeat a similar process for
the Signin Activity.

>java
// SignupActivity.java

import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;

public class SignupActivity extends AppCompatActivity {

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

// Implement signup functionality here


}
}

Output:

45
MEC / IT / MOBILE APPLICATION LABORATORY
Result:

Upon completion of this lab, you will have successfully developed and designed signup and signin pages
for a calculator application using Android Studio, enhancing the user experience and providing secure
authentication functionality.

46
MEC / IT / MOBILE APPLICATION LABORATORY
c.Developing Signup and Signin Pages in Weather Application

Aim:

The aim of this lab is to design and implement signup and signin pages for a Weather Application using
Android Studio. This will involve creating user interfaces for user registration and authentication, as
well as programming the necessary functionalities.

Procedure:

1. Setup:
- Open Android Studio and create a new Android project.
- Choose an appropriate project name and package.
- Select a blank activity template.

2. Design Signup Page:


- Open `res/layout/activity_signup.xml` and design the signup page layout.
- Include necessary components such as EditText for username, email, password, and a button for
signup.
- Use appropriate input types and add constraints for responsive design.

3. Implement Signup Logic:


- Navigate to `SignUpActivity.java`.
- Implement the logic to handle user input and perform signup using Firebase Authentication or any
preferred authentication method.
- Display relevant error messages for invalid inputs.

4. Design Signin Page:


- Open `res/layout/activity_signin.xml` and design the signin page layout.
- Include EditText for email, password, and a button for signin.
- Implement a link to navigate to the signup page for new users.

5. Implement Signin Logic:


- Navigate to `SignInActivity.java`.
- Implement the logic to authenticate users using the provided email and password.
- Display appropriate messages for successful signin or any authentication errors.

6. Connect Pages and Navigation:


- Update the `AndroidManifest.xml` to define the activities and their intent filters.
- Ensure proper navigation between signup and signin pages.

7. Test the Application:


- Run the application on an emulator or a physical device.
- Test the signup and signin functionalities to ensure proper validation and authentication.

47
MEC / IT / MOBILE APPLICATION LABORATORY
Program (Firebase Authentication):

>java
// In SignUpActivity.java
FirebaseAuth auth = FirebaseAuth.getInstance();
auth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
// Signup success
// Navigate to the main application or home page
} else {
// Signup failed, display an error message
Toast.makeText(SignUpActivity.this, "Signup failed.", Toast.LENGTH_SHORT).show();
}
});

// In SignInActivity.java
FirebaseAuth auth = FirebaseAuth.getInstance();
auth.signInWithEmailAndPassword(email, password)
.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
// Signin success
// Navigate to the main application or home page
} else {
// Signin failed, display an error message
Toast.makeText(SignInActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
}
});

Output:

48
MEC / IT / MOBILE APPLICATION LABORATORY
Result:

Upon successful implementation, the Weather Application should allow users to seamlessly signup
and signin. A successful signup or signin should transition the user to the main application screen.
Error messages should be displayed for unsuccessful attempts.

49
MEC / IT / MOBILE APPLICATION LABORATORY
d.Developing Signup and Signin Pages in Video Player Application

Aim:

The aim of this lab is to design and implement Signup and Signin pages for a Video Player Application
using Android Studio. This involves creating user interfaces for user registration and authentication
processes.

Procedure:

1. Setting up Android Studio:


- Ensure Android Studio is installed and properly configured.
- Create a new Android Studio project with an appropriate name and package.

2. Designing Signup Page:


- Create a new activity for the signup page.
- Design the user interface with necessary input fields (e.g., username, email, password).
- Implement form validation to ensure proper user input.

3. Implementing Signup Logic:


- Write code to handle user registration using Firebase Authentication or your preferred
authentication method.
- Store user data securely and handle possible error scenarios.

4. Designing Signin Page:


- Create a new activity for the signin page.
- Design the user interface with input fields for email/username and password.
- Implement form validation for the signin form.

5. Implementing Signin Logic:


- Write code to authenticate users during the signin process.
- Utilize Firebase Authentication or your chosen authentication method.
- Handle successful signins and provide feedback to the user.
- Implement error handling for unsuccessful signins.

6. Integration with Video Player:


- Ensure the Video Player component is integrated into the project.
- Implement logic to allow authenticated users access to video content.
- Restrict access for unauthenticated users.

Program:

Signup Activity (Java):

>java

50
MEC / IT / MOBILE APPLICATION LABORATORY
// Import necessary packages

public class SignupActivity extends AppCompatActivity {


// Declare UI elements and variables

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

// Initialize UI elements and set listeners


}

// Implement signup logic and error handling


}

Signin Activity (Java):

>java
// Import necessary packages

public class SigninActivity extends AppCompatActivity {


// Declare UI elements and variables

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

// Initialize UI elements and set listeners


}

// Implement signin logic and error handling


}

Output :

51
MEC / IT / MOBILE APPLICATION LABORATORY
Result:

Users will be able to seamlessly navigate through the Signup and Signin pages, providing a secure and
user-friendly experience for accessing the Video Player Application. Successful registration and
authentication will grant access to the video content, while appropriate error handling will ensure a
smooth user experience.

52
MEC / IT / MOBILE APPLICATION LABORATORY

You might also like