Professional Documents
Culture Documents
5 - 4350703 - Mad - Lab Manual
5 - 4350703 - Mad - Lab Manual
Laboratory Manual
Mobile Application Development using Android
(4350703)
Laboratory Manual
Prepared By,
Shri. Paraskumar J. Joshi, Shri. Mayukumar R. Thakkar
Lecturer, Computer Engineering Lecturer, Computer Engineering
K. D. Polytechnic, Patan K. D. Polytechnic, Patan
Branch Co-Ordinator,
Shri. B. H. Kantevala
HoD, Computer Engineering,
Govt. Polytechnic, Ahmedabad
Committee Chairman,
Shri. R. D. Raghani
HoD, Electronics & Communication,
Govt. Polytechnic, Gandhinagar
2 | Page
Mobile Application Development (4350703)
DTE’s Mission:
• To provide globally competitive technical education;
• Remove geographical imbalances and inconsistencies;
• Develop student friendly resources with a special focus on girls’ education and
support to weaker sections;
• Develop programs relevant to industry and create a vibrant pool of technical
professionals.
Institute’s Vision:
………………………………………………………………………………………..…………………
…….…………………………………………………………………………………..…………..……
………..……………………………………………………………………………….…………..……
…………..…………………………………………………………………………….……………..…
……………..………………………………………………………………………….………………..
………………..…………………………………………………………………………………………
..………………..……………………………………………………………………….……………..
Institute’s Mission:
………………………………………………………………………………………..…………………
…….…………………………………………………………………………………..…………..……
………..……………………………………………………………………………….…………..……
…………..…………………………………………………………………………….……………..…
……………..………………………………………………………………………….………………..
………………..…………………………………………………………………………………………
..………………..……………………………………………………………………….……………..
…………..…………………………………………………………………………….……………..…
……………..………………………………………………………………………….………………..
………………..…………………………………………………………………………………………
..………………..……………………………………………………………………….……………..
3 | Page
Mobile Application Development (4350703)
Department’s Vision:
………………………………………………………………………………………..…………………
…….…………………………………………………………………………………..…………..……
………..……………………………………………………………………………….…………..……
…………..…………………………………………………………………………….……………..…
……………..………………………………………………………………………….………………..
………………..…………………………………………………………………………………………
..………………..……………………………………………………………………….……………..
Department’s Mission:
………………………………………………………………………………………..…………………
…….…………………………………………………………………………………..…………..……
………..……………………………………………………………………………….…………..……
…………..…………………………………………………………………………….……………..…
……………..………………………………………………………………………….………………..
………………..…………………………………………………………………………………………
..………………..……………………………………………………………………….……………..
………………………………………………………………………………………..…………………
…….…………………………………………………………………………………..…………..……
………..……………………………………………………………………………….…………..……
…………..…………………………………………………………………………….……………..…
……………..………………………………………………………………………….………………..
………………..…………………………………………………………………………………………
..………………..……………………………………………………………………….……………..
4 | Page
Mobile Application Development (4350703)
Institute: ________________________________________________
Certificate
Place: …………………..
Date: …………………..
5 | Page
Mobile Application Development (4350703)
Preface
The primary aim of any laboratory/Practical/field work is enhancement of required skills as
well as creative ability amongst students to solve real time problems by developing relevant
competencies in psychomotor domain. Keeping in view, GTU has designed competency focused
outcome-based curriculum -2021 (COGC-2021) for Diploma engineering programmes. In this more
time is allotted to practical work than theory. It shows importance of enhancement of skills amongst
students and it pays attention to utilize every second of time allotted for practical amongst Students,
Instructors and Lecturers to achieve relevant outcomes by performing rather than writing practice in
study type. It is essential for effective implementation of competency focused outcome- based
Green curriculum-2021. Every practical has been keenly designed to serve as a tool to develop &
enhance relevant industry needed competency in each and every student. These psychomotor skills
are very difficult to develop through traditional chalk and board content delivery method in the
classroom. Accordingly, this lab manual has been designed to focus on the industry defined relevant
outcomes, rather than old practice of conducting practical to prove concept and theory.
By using this lab manual, students can read procedure one day in advance to actual
performance day of practical experiment which generates interest and also, they can have idea of
judgement of magnitude prior to performance. This in turn enhances predetermined outcomes
amongst students. Each and every Experiment /Practical in this manual begins by competency,
industry relevant skills, course outcomes as well as practical outcomes which serve as a key role for
doing the practical. The students will also have a clear idea of safety and necessary precautions to be
taken while performing experiment.
This manual also provides guidelines to lecturers to facilitate student-centered lab activities
for each practical/experiment by arranging and managing necessary resources in order that the
students follow the procedures with required safety and necessary precautions to achieve
outcomes. It also gives an idea that how students will be assessed by providing Rubrics.
Smartphones and mobile applications have grown in popularity in recent years. This trend is
expected to continue, resulting in an increased demand for professionals who can create mobile
applications. Android mobile application development is a relevant and important topic for
computer engineering students because it allows them to apply their programming skills and
knowledge to create real-world applications. The course provides students with hands-on
experience in developing mobile applications using Android. This practical experience is essential for
students to be able to apply the concepts they have learned in a real-world setting. This course will
6 | Page
Mobile Application Development (4350703)
help students to build core competencies in mobile application development with relevant skills and
knowledge, practical experience, and career opportunities in a growing and dynamic industry.
Although we try our level best to design this lab manual, there are always chances of
improvement. We welcome any suggestions for improvement.
7 | Page
Mobile Application Development (4350703)
1. Basic and Discipline specific knowledge: Apply knowledge of basic mathematics, science and
engineering fundamentals and engineering specialization to solve the engineering problems.
2. Problem analysis: Identify and analyse well-defined engineering problems using codified
standard methods.
3. Design/development of solutions: Design solutions for engineering well-defined technical
problems and assist with the design of systems components or processes to meet specified
needs.
4. Engineering Tools, Experimentation and Testing: Apply modern engineering tools and
appropriate technique to conduct standard tests and measurements.
5. Engineering practices for society, sustainability and environment: Apply appropriate
technology in context of society, sustainability, environment and ethical practices.
6. Project Management: Use engineering management principles individually, as a team member
or a leader to manage projects and effectively communicate about well-defined engineering
activities.
7. Life-long learning: Ability to analyse individual needs and engage in updating in the context of
technological changes in field of engineering.
8 | Page
Mobile Application Development (4350703)
10 | Page
Mobile Application Development (4350703)
Guidelines to Teachers
1. Couse faculty should demonstrate experiment with all necessary implementation strategies
described in curriculum.
2. Couse faculty should explain industrial relevance before starting of each experiment.
3. Course faculty should involve & give opportunity to all students for hands on experience.
4. Course faculty should ensure mentioned skills are developed in the students by asking.
5. Utilise 2 hrs of lab hours effectively and ensure completion of write up with quiz also.
6. Encourage peer to peer learning by doing same experiment through fast learners.
11 | Page
Mobile Application Development (4350703)
Assessment Rubrics
Criteria % Rubrics
Excellent [4-5 marks]:
• Student is able to analyse the problem statement and propose/design the
Rubric (RB1):
solution of the problem statement efficiently.
Problem
Adequate [2-3 marks]:
analysis and
20 % • Student is able to analyse the problem statement and propose/design the
proposing
solution of the problem statement satisfactorily
/designing
Unsatisfactory [0-1 marks]:
solution
• Student is not able to understand the problem statement and not able to
propose or design the solution completely.
Excellent [7-8 marks]:
• Completed programs correctly as per the requirements.
Rubric (RB2): Adequate [5-6 marks]:
Program • Completed programs correctly with approx. 70% requirements.
30%
Completeness Satisfactory [3-4 marks]:
/ Correctness • Completed programs correctly with 70% - 50% requirements.
Unsatisfactory [0-2 marks]:
• Completed programs correctly with less than 50% requirements.
Excellent [4-5 marks]:
• The code is efficient, clean, well-organized, and very easy to understand.
Satisfactory[2-3 marks]:
Rubric (RB3): • The code is readable only by someone who knows what it is supposed to
Code 20 % be doing.
efficiency • The code is not up to the mark of efficiency.
Unsatisfactory [0-1 marks]:
• The code is poorly organized and very difficult to understand.
• The code is inefficient.
Excellent [4-5 marks]:
• The documentation and lab records with programming code and output
is written neatly and accurately.
Rubric (RB4): • The timely submission for the practical assessment is done.
Readability Satisfactory [2-3 marks]:
and • The documentation and lab records with programming code and output
20 %
Documentati is written satisfactorily with some correction.
on of the • The timely submission for the practical assessment is done.
program Unsatisfactory [0-1 marks]:
• The documentation and lab records with programming code and output
is written poorly.
• The late submission for the practical assessment is done.
Excellent [2 marks]:
• Student demonstrates full knowledge by answering allclass questions
Rubric(RB5): with explanations and elaboration.
Viva/Sample Satisfactory [1marks]:
10 %
question • Student is uncomfortable with info and is able to answer only basics.
answering Unsatisfactory [0 marks]:
• Student does not grasp any information, and student cannot answer
question about practical.
12 | Page
Mobile Application Development (4350703)
13 | Page
Mobile Application Development (4350703)
14 | Page
Mobile Application Development (4350703)
Practical No.1
Set-up of Android development environment, managing AVD and understanding its
various components.
A. Objective:
This practical will help student to set up an android development environment to write,
compile and debug android application. It will also help students to create and use AVD
to test and run android application, and to understand various components of an android
application.
15 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
The practical does not require knowledge of any prerequisite theory. The steps for the
installation and the setup is to be followed by the students which is explained in the
following section.
H. Experimental set up/ Program Logic-Flow chart (CE & IT 1st and 2nd semester
software subjects only):
Android Studio is the official integrated development environment (IDE) for Android app,
development built and distributed by Google. An IDE contains tools that enable software
developers to design, build, run, and test software, in this case, apps for the Android
platform. Android Studio uses IntelliJ IDEA as its foundation and includes the Android
plugin pre-installed along with some modifications specifically for the Android platform.
16 | Page
Mobile Application Development (4350703)
17 | Page
Mobile Application Development (4350703)
9. During the installation, the setup wizard downloads and installs additional
components and tools needed for Android app development. This may take some
time depending on your internet speed. During this time, you may see a User
Account Control dialog for Windows Command Processor. Click Yes to accept the
dialog.
10. You may also receive a Windows Security Alert about adb.exe. Click Allow Access, if
needed, to continue the installation.
11. When the download and installation completes, click Finish.
12. The Welcome to Android Studio window displays and you're ready to start creating
apps.
To open the SDK Manager from Android Studio, click Tools > SDK Manager or
dash appears in
the check box next to
the package.
To update an item or
install a new one, click
the check box so it
shows a checkmark.
To uninstall a package,
click to clear the check
box.
Recommended packages:
You should give special consideration to the following tools in the SDK Tools tab:
• ANDROID SDK BUILD-TOOLS
• REQUIRED. Includes tools to build Android apps.
• Android SDK Platform-Tools
• REQUIRED. Includes various tools required by the Android
platform, including the adb tool.
• ANDROID SDK TOOLS
• REQUIRED. Includes essential tools such as ProGuard.
About AVDs:
An AVD contains a hardware profile, system image, storage area, skin, and other
properties. We recommend that you create an AVD for each system image that your app
could potentially support based on the<uses-sdk> setting in your manifest.
19 | Page
Mobile Application Development (4350703)
Create an AVD
To create a new AVD:
7. Select the system image for a particular API level, and then click NEXT.
8. The RECOMMENDED tab lists recommended system images. The other tabs include
a more complete list. The right pane describes the selected system image. x86
images run the fastest in the emulator.
9. If you see DOWNLOAD next to the system image, you need to click it to download
the system image. You must be connected to the internet to download it.
10. The API level of the target device is important, because your app won't be able to run
on a system image with an API level that's less than that required by your app, as
specified in the minSdkVersion attribute of the app manifest file.
20 | Page
Mobile Application Development (4350703)
13. Click SHOW ADVANCED SETTINGS to show more settings, such as the skin.
14. The new AVD appears in the Your Virtual Devices page or the Select Deployment
Target dialog.
21 | Page
Mobile Application Development (4350703)
22 | Page
Mobile Application Development (4350703)
3. In Android Studio on your computer, make sure your device is selected in the
dropdown. Click .
4. Select your device and then click OK. Android Studio installs the app on your
device and runs it.
5. If your device runs an Android platform that isn't installed in Android Studio
and you see a message that asks whether you want to install the needed
platform, click INSTALL > CONTINUE > FINISH. Android Studio installs the app
on your device and runs it.
Run your app on the Android device with Wi-Fi:
If you don't have a cable, you can also connect and run your app on your device with Wi-
Fi.
Get started:
1. Ensure that your computer and device are connected to the same wireless
network.
2. Ensure that your device runs Android 11 or higher. For more information,
see Check & update your Android version.
3. Ensure that your computer has the latest version of Android Studio. To
download it, see Android Studio.
4. Ensure that your computer has the latest version of the SDK Platform Tools.
23 | Page
Mobile Application Development (4350703)
3. Go to DEVELOPER
OPTIONS, scroll down
to
the DEBUGGING section
and turn on WIRELESS
DEBUGGING.
4. On the ALLOW
WIRELESS DEBUGGING
ON THIS
NETWORK? popup,
select ALLOW.
24 | Page
Mobile Application Development (4350703)
I. Assessment-Rubrics
Assessment Criteria Obtained
Marks
Rubric (RB1): Problem analysis and proposing/designing solution /5
Rubric (RB2): Program Completeness/ Correctness /8
Rubric (RB3): Code efficiency /5
Rubric (RB4): Readability and Documentation of the program /5
Rubric(RB5): Viva/Sample question answering /2
Total Obtained Marks /25
25 | Page
Mobile Application Development (4350703)
Practical No. 2
Understanding of Various Components available in Android Application
A. Objective:
This practical will help student to understand the basic components of
Android application. The understanding of the Android components will be
helpful to the students for the application of appropriate components while
developing the Android application.
26 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
Application components are the essential building blocks of an Android
application. These components are loosely coupled by the application
manifest file AndroidManifest.xml that describes each component of the
application and how they interact.
There are following four main components that can be used within an
Android application:
Activities:
1 They dictate the UI and handle the user interaction to the smart
phone screen.
Services:
2 They handle background processing associated with an
application.
Broadcast Receivers:
3 They handle communication between Android OS and
applications.
Content Providers:
4
They handle data and database management issues.
Activities:
An activity represents a single screen with a user interface, in-short Activity
performs actions on the screen. For example, an email application might have
one activity that shows a list of new emails, another activity to compose an
email, and another activity for reading emails. If an application has more than
one activity, then one of them should be marked as the activity that is
presented when the application is launched.
• An activity is implemented as a subclass of Activity class as follows −
public class MainActivity extends Activity {
}
Services:
A service is a component that runs in the background to perform long-running
operations. For example, a service might play music in the background while
27 | Page
Mobile Application Development (4350703)
the user is in a different application, or it might fetch data over the network
without blocking user interaction with an activity.
• A service is implemented as a subclass of Service class as follows −
public class MyService extends Service {
}
Broadcast Receivers:
Broadcast Receivers simply respond to broadcast messages from other
applications or from the system. For example, applications can also initiate
broadcasts to let other applications know that some data has been
downloaded to the device and is available for them to use, so this is broadcast
receiver who will intercept this communication and will initiate appropriate
action.
• A broadcast receiver is implemented as a subclass
of BroadcastReceiver class and each message is broadcaster as
an Intent object.
public class MyReceiver extends BroadcastReceiver {
public void onReceive(Context, Intent){}
}
Content Providers:
A content provider component supplies data from one application to others
on request. Such requests are handled by the methods of
the ContentResolver class. The data may be stored in the file system, the
database or somewhere else entirely.
• A content provider is implemented as a subclass of ContentProvider class
and must implement a standard set of APIs that enable other applications
to perform transactions.
public class MyContentProvider extends
ContentProvider {
public void onCreate(){}
}
We will go through these tags in detail while covering application components
in individual chapters.
Additional Components
There are additional components which will be used in the construction of
above-mentioned entities, their logic, and wiring between them. These
components are:
28 | Page
Mobile Application Development (4350703)
Fragments:
1
Represents a portion of user interface in an Activity.
Views:
2 UI elements that are drawn on-screen including buttons, lists
forms etc.
Layouts:
3 View hierarchies that control screen format and appearance of
the views.
Intents:
4
Messages wiring components together.
Resources:
5 External elements, such as strings, constants and drawable
pictures.
Manifest:
6
Configuration file for the application.
J. Assessment-Rubrics
29 | Page
Mobile Application Development (4350703)
Practical No.3
Develop a “Hello World” Application in Android.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
30 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
Each activity is given a window in which to draw its user interface. Activities
use Views like TextView, Button etc. to form graphical user interfaces that
display information and interact with user actions. In this practical to display
the text “Hello World”, it only requires one TextView with “Hello World” as its
text property value.
31 | Page
Mobile Application Development (4350703)
The New Project window opens with a list of templates provided by Android
Studio.
In Android Studio, a project template is an Android project that provides the
blueprint for a certain type of app. Templates create the structure of the
project and the files needed for Android Studio to build your project. The
template that you choose provides starter code to get you going faster.
3. Make sure the Phone and Tablet tab is selected.
4. Click the Empty Activity template to select it as the template for your
project. The Empty Activity template is the template to create a simple
project that you can use to build a compose application. It has a single
screen and displays the text "Hello Android!".
5. Click Next. The New Project dialog opens. This has some fields to
configure your project.
6. Configure your project as follows:
7. The Name field is used to enter the name of your project, for this code lab
type "Greeting Card".
Leave the Package name field as it is. This is how your files will be organized
in the file structure. In this case, the package name will
be com.example.greetingcard.
Leave the Save location field as it is. It contains the location where all the files
related to your project are saved. Take a note of where that is on your
computer so that you can find your files.
32 | Page
Mobile Application Development (4350703)
Select whichever version you would like to select from the menu in
the Minimum SDK field. Minimum SDK indicates the minimum version of
Android that your app can run on.
8. Click Finish. This may take a while. While Android Studio is setting up, a
progress bar and message indicates whether Android Studio is still setting
up your project. It may look like this:
A message that looks similar to this informs you when the project set up is
created.
9. Click Split on the top right of Android Studio, this allows you to view both
code and design. You can also click Code to view code only or
click Design to view design only.
33 | Page
Mobile Application Development (4350703)
• The Project view (1) shows the files and folders of your project.
• The Code view (2) is where you edit code.
• The Design view (3) is where you preview what your app looks like.
In the Design view, you will see a blank pane with this text:
10. Click BUILD & REFRESH. It may take a while to build but when it is done
the preview shows a text box that says "HELLO ANDROID!". Empty
Compose activity contains all the code necessary to create this app.
34 | Page
Mobile Application Development (4350703)
H. Resources/Equipment Required
Sr.No. Instrument/Equipment
Specification
/Components/Trainer kit
Processor: x86_64 CPU architecture
1 Computer System RAM: 8 GB Recommended
Operating System: Windows 10
I. Application Code
35 | Page
Mobile Application Development (4350703)
J. Output
36 | Page
Mobile Application Development (4350703)
L. References
https://developer.android.com/training/basics/firstapp
https://www.tutorialspoint.com/android/android_hello_world_example.htm
https://www.javatpoint.com/hello-android-example
M. Assessment-Rubrics
37 | Page
Mobile Application Development (4350703)
Practical No.4
Develop Android Application to demonstrate methods of Activity Life Cycle.
A. Objective:
After performing the practical, students will be able to understand life cycle of
an activity and implement different methods that are being executed during
the activity life cycle.
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
38 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory
The activity life cycle in Android refers to the set of states that an activity goes
through during its lifetime. Understanding the activity life cycle is essential for
building robust and responsive Android applications. The activity life cycle
consists of several callback methods that are invoked as an activity transitions
between different states.
39 | Page
Mobile Application Development (4350703)
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification
No.
/Components/Trainer kit
Processor: x86_64 CPU architecture
1. Computer System RAM: 8 GB Recommended
Operating System: Windows 10
40 | Page
Mobile Application Development (4350703)
I. Application Code
41 | Page
Mobile Application Development (4350703)
42 | Page
Mobile Application Development (4350703)
43 | Page
Mobile Application Development (4350703)
J. Output
44 | Page
Mobile Application Development (4350703)
4. Which activity life cycle method is called first when activity comes back to
foreground again?
a) onResume()
b) onRestart()
c) onStart()
d) onCreate()
5. Which is not valid activity life cycle state?
a) Running
b) Stopped
c) Printing
d) Paused
L. References
https://developer.android.com/guide/components/activities/activity-lifecycle
https://www.geeksforgeeks.org/activity-lifecycle-in-android-with-demo-app/
https://www.javatpoint.com/android-life-cycle-of-activity
https://www.tutorialspoint.com/android/android_acitivities.htm
M. Assessment-Rubrics
45 | Page
Mobile Application Development (4350703)
Practical No. 5
Design Android Activities using LinearLayout, RelativeLayout, GridLayout,
FrameLayou, and ConstraintLayout.
A. Objective:
After performing the practical, students will be able to design the Activity
using LinearLayout, RelativeLayout, GridLayout, FrameLayout, and
ConstraintLayout.
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
46 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
LinearLayout:
</LinearLayout>
RelativeLayout:
47 | Page
Mobile Application Development (4350703)
android:layout_alignParentTop, android:layout_alignParentBottom,
android:layout_alignParentStart, android:layout_alignParentEnd,
android:layout_alignStart, android:layout_alignEnd,
android:layout_above, android:layout_below, etc.
2. Alignment: RelativeLayout provides control over the alignment of child
views within the layout. You can use attributes like
android:layout_alignLeft, android:layout_alignRight,
android:layout_alignTop, android:layout_alignBottom,
android:layout_centerHorizontal, android:layout_centerVertical,
android:layout_centerInParent, etc., to align child views in relation to
each other or to the parent container.
3. Margins: RelativeLayout allows you to define margins around child views
using attributes such as android:layout_marginTop,
android:layout_marginBottom, android:layout_marginStart,
android:layout_marginEnd, android:layout_marginLeft,
android:layout_marginRight, etc. Margins help in creating spacing
between views and the parent container.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</RelativeLayout>
Inside the RelativeLayout, you can define child views and set their positioning
attributes to position them relative to the parent container or relative to
other child views.
GridLayout:
48 | Page
Mobile Application Development (4350703)
The number of occupied rows and columns by a child view can also be
specified using android:layout_rowSpan and android:layout_columnSpan.
3. Alignment: GridLayout supports alignment options to control how child
views are positioned within their respective grid cells. Alignment
attributes such as android:layout_gravity, android:layout_rowGravity, and
android:layout_columnGravity can be used to define the gravity of child
views within their cells.
4. Margins: You can apply margins to child views in a GridLayout using
attributes like android:layout_marginTop, android:layout_marginBottom,
android:layout_marginStart, android:layout_marginEnd,
android:layout_marginLeft, android:layout_marginRight, etc. These
attributes allow you to create spacing between views and the grid cells.
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:rowCount="3"
android:columnCount="3">
</GridLayout>
In the example above, GridLayout is set to have 3 rows and 3 columns. You
can adjust the number of rows and columns based on your layout
requirements.
Inside the GridLayout, you can define child views and use the layout-related
attributes to specify the position of each view within the grid.
FrameLayout:
49 | Page
Mobile Application Development (4350703)
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
Inside the FrameLayout, you can add multiple child views, and they will be
stacked in the order they are added.
ConstraintLayout:
50 | Page
Mobile Application Development (4350703)
</androidx.constraintlayout.widget.ConstraintLayout>
Inside the ConstraintLayout, you can add child views and set their constraints
using various layout-related attributes.
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification
No.
/Components/Trainer kit
Processor: x86_64 CPU architecture
1. Computer System RAM: 8 GB Recommended
Operating System: Windows 10
51 | Page
Mobile Application Development (4350703)
I. Application Code:
LinearLayout:
Layout Code (xml file)
52 | Page
Mobile Application Development (4350703)
LinearLayout Output:
53 | Page
Mobile Application Development (4350703)
RelativeLayout:
Layout Code (xml file)
54 | Page
Mobile Application Development (4350703)
RelativeLayout Output:
55 | Page
Mobile Application Development (4350703)
GridLayout:
Layout Code (xml file)
56 | Page
Mobile Application Development (4350703)
GridLayout Output:
57 | Page
Mobile Application Development (4350703)
FrameLayout:
Layout Code (xml file)
58 | Page
Mobile Application Development (4350703)
FrameLayout Output:
59 | Page
Mobile Application Development (4350703)
ConstraintLayout:
Layout Code (xml file)
60 | Page
Mobile Application Development (4350703)
ConstraintLayout Output:
61 | Page
Mobile Application Development (4350703)
K. References
https://developer.android.com/develop/ui/views/layout/declaring-layout
https://www.geeksforgeeks.org/android-ui-layouts/
https://www.tutorialspoint.com/android/android_user_interface_layouts.htm
L. Assessment-Rubrics
62 | Page
Mobile Application Development (4350703)
Practical No.6
Design various Activities using different Layouts and available widgets (TextView,
EditText, Button, RadioButton, CheckBox, ImageButton, ToggleButton, TimePicker,
DatePicker, ProgressBar, ImageView) to make the user-friendly GUI.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
63 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
Android UI Widgets/Controls
There are number of UI controls provided by Android that allow you to build
the graphical user interface for your app.
Sr. UI Widget Description
No.
1 TextView This control is used to display text to the user.
EditText EditText is a predefined subclass of TextView that
2
includes rich editing capabilities.
The AutoCompleteTextView is a view that is
similar to EditText, except that it shows a list of
3 AutoCompleteTextView
completion suggestions automatically while the
user is typing.
A push-button that can be pressed, or clicked, by
4 Button
the user to perform an action.
An ImageButton is an AbsoluteLayout which
ImageButton enables you to specify the exact location of its
5 children. This shows a button with an image
(instead of text) that can be pressed or clicked by
the user.
An on/off switch that can be toggled by the user.
CheckBox
You should use check box when presenting users
6
with a group of selectable options that are not
mutually exclusive.
7 ToggleButton An on/off button with a light indicator.
64 | Page
Mobile Application Development (4350703)
<TextView
android:id="@+id/text_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="I am a TextView" />
</LinearLayout>
Then you can create an object of the widget control and capture it from the
layout, using the following code:
Once you have the widget control in object form, you can manipulate it like
setting text or getting text as follow:
H. Resources/Equipment Required:
Sr. Instrument/Equipment
Specification
No.
/Components/Trainer kit
Processor: x86_64 CPU architecture
1. Computer System RAM: 8 GB Recommended
Operating System: Windows 10
65 | Page
Mobile Application Development (4350703)
I. Application Code:
First Activity:
Layout Code (xml file)
66 | Page
Mobile Application Development (4350703)
67 | Page
Mobile Application Development (4350703)
68 | Page
Mobile Application Development (4350703)
Second Activity:
Layout Code (xml file)
69 | Page
Mobile Application Development (4350703)
70 | Page
Mobile Application Development (4350703)
71 | Page
Mobile Application Development (4350703)
K. References:
https://developer.android.com/develop/ui
https://data-flair.training/blogs/android-ui-controls/
https://www.tutorialspoint.com/android/android_user_interface_controls.ht
m
L. Assessment-Rubrics
Practical No.7
Develop code to demonstrate different ways of handling different events over
Button, EditText etc. to perform action in android application at run-time.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
73 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
In Android, there are different ways to handle different events based on the
type of event and the desired behavior. Here are some common event
handling mechanisms and their corresponding ways of implementation:
2. Touch Event:
• Set an OnTouchListener on a View object and implement the onTouch()
method to handle different touch events like touch down, touch up, or
touch move.
ImageViewmyImage = findViewById(R.id.my_image);
myImage.setOnTouchListener(new View.OnTouchListener() {
@Override
public booleanonTouch(View v, MotionEvent event) {
// Actions to be performed based on touch events
return true;
}
});
74 | Page
Mobile Application Development (4350703)
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
// Actions to be performed while text is changing
}
@Override
public void afterTextChanged(Editable s) {
// Actions to be performed after text has changed
}
});
These are just a few examples of handling different events in Android using
specific event handling mechanisms. Depending on your application's
requirements, you may need to use other mechanisms or implement custom
event handling logic to handle events such as sensor events, broadcast
events, or gestures.
H. Resources/Equipment Required:
Sr. Instrument/Equipment
Specification
No.
/Components/Trainer kit
Processor: x86_64 CPU architecture
1. Computer System RAM: 8 GB Recommended
Operating System: Windows 10
75 | Page
Mobile Application Development (4350703)
I. Application Code:
76 | Page
Mobile Application Development (4350703)
77 | Page
Mobile Application Development (4350703)
78 | Page
Mobile Application Development (4350703)
J. Output:
79 | Page
Mobile Application Development (4350703)
80 | Page
Mobile Application Development (4350703)
Practical No.8
Develop code to demonstrate Event handling of CheckBox and RadioButton
selection.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
81 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
1. CheckBox:
• Identify the CheckBox view in your layout XML file or programmatically
create an instance of the CheckBox class.
• Set an OnCheckedChangeListener on the CheckBox object using the
setOnCheckedChangeListener() method.
• Implement the onCheckedChanged() method of the
OnCheckedChangeListener to handle changes in the checked state of the
CheckBox.
CheckBoxmyCheckBox = findViewById(R.id.my_checkbox);
myCheckBox.setOnCheckedChangeListener(new
CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged
(CompoundButtonbuttonView, Boolean isChecked) {
// Actions to be performed when the checkbox is
checked/unchecked
if (isChecked) {
// Checkbox is checked
} else {
// Checkbox is unchecked
}
}
});
2. RadioButton:
• Create a RadioGroup in your layout XML file and add RadioButton views as
child elements.
• Set an OnCheckedChangeListener on the RadioGroup object using the
setOnCheckedChangeListener() method.
• Implement the onCheckedChanged() method of the
OnCheckedChangeListener to handle changes in the checked state of the
RadioButtons.
RadioGroupradioGroup = findViewById(R.id.radio_group);
radioGroup.setOnCheckedChangeListener(new
RadioGroup.OnCheckedChangeListener() {
@Override
82 | Page
Mobile Application Development (4350703)
H. Resources/Equipment Required:
Sr. Instrument/Equipment
Specification
No.
/Components/Trainer kit
Processor: x86_64 CPU architecture
1. Computer System RAM: 8 GB Recommended
Operating System: Windows 10
I. Application Code:
83 | Page
Mobile Application Development (4350703)
84 | Page
Mobile Application Development (4350703)
85 | Page
Mobile Application Development (4350703)
J. Output:
86 | Page
Mobile Application Development (4350703)
Practical No.9
Develop code to navigate between different activities and pass the data from one
activity to other activity using Intent.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
88 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
To navigate between different activities and pass data from one activity to
another in Android, you can use the Intent mechanism. Here's an example
that demonstrates how to achieve this:
Here, "key" represents the key under which the data is passed, and "value"
represents the actual data you want to pass. You can use different keys for
different data items.
3. In ActivityB, retrieve the passed data from the Intent in the onCreate()
method.
Intent intent = getIntent();
if (intent != null) {
String data = intent.getStringExtra("key"); // Retrieve
the data using the key
// Use the retrieved data as needed
}
Here, "key" should match the key used in ActivityA to pass the data.
4. You can also pass other data types using different methods such as
getIntExtra(), getBooleanExtra(), etc., depending on the data type you
want to retrieve.
int intValue = intent.getIntExtra("intKey", defaultValue);
booleanboolValue = intent.getBooleanExtra("boolKey",
defaultValue);
// Retrieve other data types as needed
Make sure to provide default values that will be used if the data is not found
or if there is an issue with the data type.
89 | Page
Mobile Application Development (4350703)
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification
No.
/Components/Trainer kit
Processor: x86_64 CPU architecture
1. Computer System RAM: 8 GB Recommended
Operating System: Windows 10
I. Application Code:
ActivityA:
Layout Code (xml file)
90 | Page
Mobile Application Development (4350703)
91 | Page
Mobile Application Development (4350703)
ActivityA Output:
92 | Page
Mobile Application Development (4350703)
ActivityB:
Layout Code (xml file)
93 | Page
Mobile Application Development (4350703)
ActivityB Output:
94 | Page
Mobile Application Development (4350703)
4. What should you do if the retrieved data is not found or if there is an issue
with the data type?
a) Ignore the data and continue execution.
b) Throw an exception and terminate the application.
c) Provide default values or handle the error gracefully.
d) Retry retrieving the data until it is available.
K. References:
https://developer.android.com/guide/components/intents-filters
https://www.geeksforgeeks.org/what-is-intent-in-android/
https://www.tutorialspoint.com/what-is-an-intent-in-android
https://www.javatpoint.com/android-intent-tutorial
L. Assessment-Rubrics
Assessment Criteria Obtained
Marks
Rubric (RB1): Problem analysis and proposing/designing solution /5
Rubric (RB2): Program Completeness/ Correctness /8
Rubric (RB3): Code efficiency /5
Rubric (RB4): Readability and Documentation of the program /5
Rubric(RB5): Viva/Sample question answering /2
Total Obtained Marks /25
95 | Page
Mobile Application Development (4350703)
Practical No. 10
Develop an android application to store data locally using SharedPreferences and
access, modify in different activities.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
96 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
In android, data can be stored locally and stored data can be access, modify in
different activities using SharedPreferences.
1. Storing Data:
• In the activity where you want to store the data, create an instance of
SharedPreferences using the getSharedPreferences() method.
• Retrieve the SharedPreferences editor using the edit() method.
• Use the editor's methods e.g., putString(), putInt(), putBoolean() to store
the data.
• Call the apply() or commit() method to save the changes.
2. Accessing/Modifying Data:
• In another activity e.g., ActivityB where you want to access or modify the
stored data, retrieve the SharedPreferences instance using
getSharedPreferences().
• Use the SharedPreferences object to retrieve the stored data using
methods like getString(), getInt(), getBoolean().
• Modify the data if needed using the editor obtained from the
SharedPreferences object.
• Call apply() or commit() to save the modifications.
97 | Page
Mobile Application Development (4350703)
H. Resources/Equipment Required:
Sr. Instrument/Equipment
Specification
No.
/Components/Trainer kit
Processor: x86_64 CPU architecture
1. Computer System RAM: 8 GB Recommended
Operating System: Windows 10
I. Application Code:
ActivityA:
Layout Code (xml file)
98 | Page
Mobile Application Development (4350703)
ActivityA Output:
99 | Page
Mobile Application Development (4350703)
ActivityB:
Layout Code (xml file)
100 | Page
Mobile Application Development (4350703)
ActivityB Output:
101 | Page
Mobile Application Development (4350703)
102 | Page
Mobile Application Development (4350703)
Practical No.11
Develop the code to implement the ListView and the Spinner views, perform add,
update, remove items operations, and implement the item selection event handling
over ListView and Spinner for appropriate example.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
D. Expected Course Outcomes (COs):
• Apply Event Handling in Android application to perform user actions.
103 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
1. ListView :
104 | Page
Mobile Application Development (4350703)
• Adding an item:
String newItem = "Android";
• Updating an item:
// Get the position of the item you want to update
int position = 2;
• Removing an item:
// Get the position of the item you want to remove
int position = 2;
2. Spinner:
Android spinner is like the drop down menu with multiple values from which
the end user can select only one value.Android spinner is associated with
AdapterView. So you need to use one of the adapter classes with spinner.
• Attributes of Spinner:
Attributes Description
android:id Used to specify the id of the view.
android:textAlignment Used to the text alignment in the dropdown list.
android:background Used to set the background of the view.
android:padding Used to set the padding of the view.
android:visibility Used to set the visibility of the view.
android:gravity Used to specify the gravity of the view like center, top,
bottom, etc.
105 | Page
Mobile Application Development (4350703)
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
own_item);
@Override
public void onNothingSelected(AdapterView<*> arg0)
{
// Auto-generated method stub
}
}
106 | Page
Mobile Application Development (4350703)
• Adding an item:
Spinner spinner = findViewById(R.id.coursesspinner);
ArrayAdapter<String> adapter = (ArrayAdapter<String>)
spinner.getAdapter();
• Updating an item:
Spinner spinner = findViewById(R.id.coursesspinner);
ArrayAdapter<String> adapter = (ArrayAdapter<String>)
spinner.getAdapter();
• Removing an item:
Spinner spinner = findViewById(R.id.coursesspinner);
ArrayAdapter<String> adapter = (ArrayAdapter<String>)
spinner.getAdapter();
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification
No.
/Components/Trainer kit
Processor: x86_64 CPU architecture
1. Computer System RAM: 8 GB Recommended
Operating System: Windows 10
107 | Page
Mobile Application Development (4350703)
I. Application Code:
ListView:
Layout Code (xml file)
108 | Page
Mobile Application Development (4350703)
109 | Page
Mobile Application Development (4350703)
110 | Page
Mobile Application Development (4350703)
Output:
111 | Page
Mobile Application Development (4350703)
Spinner:
Layout Code (xml file)
112 | Page
Mobile Application Development (4350703)
113 | Page
Mobile Application Development (4350703)
114 | Page
Mobile Application Development (4350703)
Output:
115 | Page
Mobile Application Development (4350703)
116 | Page
Mobile Application Development (4350703)
Practical No.12
Develop the code to manage permission using manifest file and run time from
activity, and toggle state of Wi-Fi and Bluetooth.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
117 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
Manifest.permission.BLUETOOTH) != PackageManager.PERMISSION_GRANTED
|| ContextCompat.checkSelfPermission(this,
Manifest.permission.BLUETOOTH_ADMIN) !=
PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(this, new String[]{
Manifest.permission.BLUETOOTH,
Manifest.permission.BLUETOOTH_ADMIN},
REQUEST_BLUETOOTH_PERMISSION);
}
// Request Wi-Fi permissions
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_WIFI_STATE) !=
PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(this,
118 | Page
Mobile Application Development (4350703)
Manifest.permission.CHANGE_WIFI_STATE) !=
PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(this, new String[]{
Manifest.permission.ACCESS_WIFI_STATE,Manifest.permission.CHAN
GE_WIFI_STATE}, REQUEST_WIFI_PERMISSION);
}
H. Resources/Equipment Required
Sr. Instrument/Equipment
Specification
No.
/Components/Trainer kit
Processor: x86_64 CPU architecture
1. Computer System RAM: 8 GB Recommended
Operating System: Windows 10
I. Application Code:
119 | Page
Mobile Application Development (4350703)
120 | Page
Mobile Application Development (4350703)
121 | Page
Mobile Application Development (4350703)
J. Output:
122 | Page
Mobile Application Development (4350703)
123 | Page
Mobile Application Development (4350703)
Practical No.13
Develop android applications to demonstrate user interaction with the application
using Options Menu, Context Menu and Popup Menu.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
124 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
1. Options Menu
• Open the activity where you want to display the options menu.
• Override the onCreateOptionsMenu() method in your activity, and inflate
the menu resource file you created.
@Override
public booleanonCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
• Optionally, you can handle the selection of menu items by overriding the
onOptionsItemSelected() method.
@Override
public booleanonOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_option1) {
// Handle option 1 selection
return true;
} else if (id == R.id.action_option2) {
// Handle option 2 selection
125 | Page
Mobile Application Development (4350703)
return true;
}
return super.onOptionsItemSelected(item);
}
• When you run your app, and the options menu should appear in the
activity you specified. When the user selects an item, the corresponding
code in the onOptionsItemSelected() method will be executed.
2. Context Menu
A context menu is a type of menu that appears when the user performs a long
press or a contextual action on a view or item. It provides a set of actions
relevant to the selected view or item.
• Register the view or item for which you want to create a context menu.
This is typically done in the onCreate() method of your activity. For
example, if you want to register a TextView with the ID "textView":
TextViewtextView = findViewById(R.id.textView);
registerForContextMenu(textView);
• Create a new XML file in your project's "res/menu" directory to define the
items in the context menu. For example, if you want to name it
"context_menu.xml", you can add the following code:
<menu xmlns:android=
"http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_edit"
android:title="Edit" />
<item
android:id="@+id/action_delete"
android:title="Delete" />
</menu>
126 | Page
Mobile Application Development (4350703)
• When you run your app, and when the user performs a long press or
contextual action on the registered view or item, the context menu will
appear. When the user selects an item, the corresponding code in the
onContextItemSelected() method will be executed.
3. Popup Menu
• Inflate the popup menu by calling the inflate() method and providing the
menu resource file you created.
popupMenu.getMenuInflater().inflate(R.menu.popup_menu,
popupMenu.getMenu());
127 | Page
Mobile Application Development (4350703)
return true;
} else if (id == R.id.action_option2) {
// Handle option 2 selection
return true;
}
return false;
}
});
• When you run your app, and when the user taps the associated view (e.g.,
button), the popup menu will appear. When the user selects an item, the
corresponding code in the OnMenuItemClickListener will be executed.
H. Resources/Equipment Required:
Sr. Instrument/Equipment
Specification
No.
/Components/Trainer kit
Processor: x86_64 CPU architecture
1. Computer System RAM: 8 GB Recommended
Operating System: Windows 10
I. Application Code:
Options Menu Example:
Layout Code (xml file)
128 | Page
Mobile Application Development (4350703)
129 | Page
Mobile Application Development (4350703)
130 | Page
Mobile Application Development (4350703)
131 | Page
Mobile Application Development (4350703)
132 | Page
Mobile Application Development (4350703)
133 | Page
Mobile Application Development (4350703)
134 | Page
Mobile Application Development (4350703)
135 | Page
Mobile Application Development (4350703)
136 | Page
Mobile Application Development (4350703)
137 | Page
Mobile Application Development (4350703)
138 | Page
Mobile Application Development (4350703)
Practical No.14
Develop Android Applications to demonstrate different AlertDialogs and the Custom
Dialog.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
139 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
1. Alert Dialog
In this example, context refers to the current context or activity where you
want to display the dialog. You can replace "Alert" and "This is an example
alert dialog" with your desired title and message. The positive and negative
buttons are specified with their labels ("OK" and "Cancel") and click listeners
to handle button clicks.
This code demonstrates a basic usage of AlertDialog, but you can customize it
further by adding other options like neutral buttons, custom views, and more.
140 | Page
Mobile Application Development (4350703)
2. Custom Dialog
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is a custom dialog"
android:textSize="18sp"
android:textColor="@android:color/black"/>
</LinearLayout>
• In your activity or fragment where you want to show the custom dialog,
create an instance of the Dialog class, set its custom view, and handle any
necessary interactions.
// Create a Dialog instance
Dialog dialog = new Dialog(context);
In this example, context refers to the current context or activity where you
want to display the custom dialog. Replace R.layout.custom_dialog with the
appropriate resource ID if your XML layout file has a different name or
location.
141 | Page
Mobile Application Development (4350703)
You can customize the dialog further by accessing the views inside the custom
layout using findViewById() and setting listeners or performing actions
accordingly.
H. Resources/Equipment Required:
Sr. Instrument/Equipment
Specification
No.
/Components/Trainer kit
Processor: x86_64 CPU architecture
1. Computer System RAM: 8 GB Recommended
Operating System: Windows 10
I. Application Code:
AlertDialog Example:
Layout Code (xml file)
142 | Page
Mobile Application Development (4350703)
143 | Page
Mobile Application Development (4350703)
144 | Page
Mobile Application Development (4350703)
AlertDialog Output:
145 | Page
Mobile Application Development (4350703)
146 | Page
Mobile Application Development (4350703)
147 | Page
Mobile Application Development (4350703)
148 | Page
Mobile Application Development (4350703)
149 | Page
Mobile Application Development (4350703)
L. Assessment-Rubrics:
Assessment Criteria Obtained
Marks
Rubric (RB1): Problem analysis and proposing/designing solution /5
Rubric (RB2): Program Completeness/ Correctness /8
Rubric (RB3): Code efficiency /5
Rubric (RB4): Readability and Documentation of the program /5
Rubric(RB5): Viva/Sample question answering /2
Total Obtained Marks /25
150 | Page
Mobile Application Development (4350703)
Practical No.15
Develop Android Application for local database connectivity and performing basic
database operations (select, insert, update, delete) using SQLiteDatabase and
SQLiteOpenHelper Classes.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
151 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
In Android, you can perform various database operations using the built-in
SQLite database. SQLite is a lightweight, embedded relational database that is
widely used in Android applications. Here's an overview of the common
database operations you can perform:
• Creating a Database: To create a database, you need to subclass the
SQLiteOpenHelper class and override the onCreate() method. Inside this
method, you can execute SQL statements to create tables and define the
database schema.
// Creating a Database
public class MyDatabaseHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME =
"mydatabase.db";
private static final int DATABASE_VERSION = 1;
@Override
public void onCreate(SQLiteDatabasedb) {
// Create tables and define schema using db.execSQL()
}
@Override
public void onUpgrade(SQLiteDatabasedb, int oldVersion,
int newVersion)
{
// Perform database schema upgrades if needed
}
}
152 | Page
Mobile Application Development (4350703)
• Inserting Data: To insert data into a table, use the SQLiteDatabase class
and its insert() method. Provide the table name, column values, and
optional nullColumnHack parameter if necessary.
// Inserting Data
ContentValues values = new ContentValues();
values.put("column_name", "value");
long newRowId = db.insert("table_name", null, values);
• Querying Data: To retrieve data from a table, use the query() method of
the SQLiteDatabase class. It allows you to specify the table name, columns
to retrieve, selection criteria, sort order, and more.
// Querying Data
String[] projection = {"column1", "column2"};
String selection = "column3 = ?";
String[] selectionArgs = {"value"};
String sortOrder = "column4 ASC";
Cursor cursor = db.query("table_name", projection, selection,
selectionArgs,
null, null, sortOrder);
if (cursor != null &&cursor.moveToFirst()) {
// Iterate over the cursor to retrieve data
cursor.close();
}
• Deleting Data: To delete data from a table, use the delete() method of the
SQLiteDatabase class. Provide the table name, selection criteria, and
optional arguments.
// Deleting Data
String whereClause = "column_name= ?";
String[] whereArgs = {"value"};
int rowsDeleted = db.delete("table_name", whereClause,
whereArgs);
153 | Page
Mobile Application Development (4350703)
H. Resources/Equipment Required:
Sr. Instrument/Equipment
Specification
No. /Components/Trainer kit
I. Application Code:
154 | Page
Mobile Application Development (4350703)
155 | Page
Mobile Application Development (4350703)
156 | Page
Mobile Application Development (4350703)
157 | Page
Mobile Application Development (4350703)
J. Output:
158 | Page
Mobile Application Development (4350703)
L. References:
https://developer.android.com/reference/android/database/sqlite/SQLiteDat
abase
https://www.geeksforgeeks.org/how-to-create-and-add-data-to-sqlite-
database-in-android/
https://www.javatpoint.com/android-sqlite-tutorial
https://www.tutorialspoint.com/android/android_sqlite_database.htm
159 | Page
Mobile Application Development (4350703)
M. Assessment-Rubrics:
160 | Page
Mobile Application Development (4350703)
Practical No.16
Develop an Android Application to demonstrate the use of RecyclerView and
CardView for displaying list of items with multiple information.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
161 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
1. RecyclerView:
• Define the RecyclerView in your XML layout file where you want to display
the list.
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
• Create a custom item layout XML file for each item in the list. This file will
define the appearance of each item in the RecyclerView.
• Create a CustomViewHolder class that extends RecyclerView.ViewHolder.
This class will hold references to the views within each item layout and
provide a way to access and update them.
public class CustomViewHolder extends
RecyclerView.ViewHolder {
// Declare views within the item layout
public TextViewtextView;
public CustomViewHolder(View itemView)
{
super(itemView);
// Initialize views
textView =
itemView.findViewById(R.id.textView);
}
}
162 | Page
Mobile Application Development (4350703)
public CustomAdapter(List<String>dataList)
{
this.dataList = dataList;
}
@Override
public CustomViewHolderonCreateViewHolder(ViewGroup
parent, int viewType)
{
View view = LayoutInflater.from(
parent.getContext()).inflate(R.layout.item_layout,
parent, false);
return new CustomViewHolder(view);
}
@Override
public void onBindViewHolder(CustomViewHolder holder, int
position)
{
String data = dataList.get(position);
holder.textView.setText(data);
}
@Override
public int getItemCount()
{
return dataList.size();
}
}
163 | Page
Mobile Application Development (4350703)
2. CardView:
• Use the CardView in your XML layout file by wrapping your content inside
the <androidx.cardview.widget.CardView> tags. Here, TextView is
wrapped inside as shown below:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/
apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context=".MainActivity">
<androidx.cardview.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="8dp"
app:cardElevation="4dp"
app:cardBackgroundColor="#FFFFFF">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This is a CardView"
android:textSize="16sp"
android:padding="16dp" />
</androidx.cardview.widget.CardView>
</RelativeLayout>
164 | Page
Mobile Application Development (4350703)
• In Java class (e.g., MainActivity.java), associate the XML layout with the
activity and initialize the CardView.
import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import android.os.Bundle;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
cardView = findViewById(R.id.cardView);
cardView.setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View v)
{
// Perform actions on card click
Toast.makeText(MainActivity.this,
"Card clicked!",
Toast.LENGTH_SHORT).show();
}
});
}
}
165 | Page
Mobile Application Development (4350703)
H. Resources/Equipment Required:
Sr. Instrument/Equipment
Specification
No. /Components/Trainer kit
I. Application Code:
RecyclerView Example:
Layout Code (xml file)
166 | Page
Mobile Application Development (4350703)
167 | Page
Mobile Application Development (4350703)
168 | Page
Mobile Application Development (4350703)
RecyclerView Output:
169 | Page
Mobile Application Development (4350703)
CardView Example:
Layout Code (xml file)
170 | Page
Mobile Application Development (4350703)
171 | Page
Mobile Application Development (4350703)
172 | Page
Mobile Application Development (4350703)
CardView Output:
173 | Page
Mobile Application Development (4350703)
K. References:
https://developer.android.com/develop/ui/views/layout/recyclerview
https://www.geeksforgeeks.org/android-recyclerview/
https://developer.android.com/develop/ui/views/layout/cardview
https://www.geeksforgeeks.org/cardview-in-android-with-example/
L. Assessment-Rubrics:
174 | Page
Mobile Application Development (4350703)
Practical No.17
Develop a simple application to display “Hello <Application Name>” using Kotlin.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
175 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
In Android, its also possible to write your application code in Kotlin in place of
Java. Kotlin file has “.kt” extention as java file has “.java” extention. The
sample code to display the application name in the TextView is shown below:
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
textView = findViewById(R.id.textView)
valapplicationName = getString(R.string.app_name)
val message = "Hello $applicationName"
textView.text = message
}
}
H. Resources/Equipment Required:
Sr. Instrument/Equipment
Specification
No. /Components/Trainer kit
176 | Page
Mobile Application Development (4350703)
I. Application Code:
177 | Page
Mobile Application Development (4350703)
J. Output:
178 | Page
Mobile Application Development (4350703)
L. References:
https://developer.android.com/kotlin
https://developer.android.com/codelabs/build-your-first-android-app-kotlin
https://kotlinlang.org/docs/android-overview.html
M. Assessment-Rubrics:
179 | Page
Mobile Application Development (4350703)
Practical No.18
Develop an android application using Kotlin having a Button “Click” and upon clicking
on that Button a Toast message “Button Clicked” should be displayed on screen
through Toast Message.
A. Objective:
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
180 | Page
Mobile Application Development (4350703)
G. Prerequisite Theory:
Button’s click event in android can be handled using Kotlin as shown below:
val button = findViewById<Button>(R.id.button)
button.setOnClickListener
{
Toast.makeText(this, "Button clicked!",
Toast.LENGTH_SHORT).show()
}
Note that, here setOnClickListener method in Kotlin does not have an onClick
method. Instead, it uses a lambda expression to define the click behavior
directly.
H. Resources/Equipment Required:
Sr. Instrument/Equipment
Specification
No. /Components/Trainer kit
I. Application Code:
181 | Page
Mobile Application Development (4350703)
182 | Page
Mobile Application Development (4350703)
J. Output:
183 | Page
Mobile Application Development (4350703)
L. References:
https://www.javatpoint.com/kotlin-android-button
https://www.digitalocean.com/community/tutorials/android-button-using-
kotlin
https://www.geeksforgeeks.org/handling-click-events-button-android/
M. Assessment-Rubrics:
184 | Page
Mobile Application Development (4350703)
Practical No.20
Publish android application on Playstore.
A. Objective:
The students will be able to generate their Android .APK and publish the
application on google playstore.
The practical is expected to develop the following skills for Android mobile
application development.
• Programming Skills
• Debugging Skills
• Critical thinking and Problem-solving
G. Prerequisite Theory:
Android requires that all APKs be digitally signed with a certificate before they
are installed on a device or updated. When releasing using Android App
Bundles, you need to sign your app bundle with an upload key before
uploading it to the Play Console, and Play App Signing takes care of the rest.
185 | Page
Mobile Application Development (4350703)
For apps distributing using APKs on the Play Store or on other stores, you
must manually sign your APKs for upload.
When you are ready to publish your app, you need to sign your app and
upload it to an app store, such as Google Play. When publishing your app to
Google Play for the first time, you must also configure Play App Signing. Play
App Signing is optional for apps created before August 2021. This section
shows you how to properly sign your app for release and configure Play App
Signing.
If you don't already have an upload key, which is useful when configuring Play
App Signing, you can generate one using Android Studio as follows:
1. In the menu bar, click Build > Generate Signed Bundle/APK.
2. In the Generate Signed Bundle or APK dialog, select Android App
Bundle or APK and click Next.
3. Below the field for Key store path, click Create new.
4. On the New Key Store window, provide the following information for
your keystore and key, as shown in figure.
5. Keystore
• Key store path: Select the location where your keystore should be
created. Also, a file name should be added to the end of the location
path with the .jks extension.
• Password: Create and confirm a secure password for your keystore.
6. Key
• Alias: Enter an identifying name for your key.
• Password: Create and confirm a secure password for your key. This
should be the same as your keystore password. (Please refer to
the known issue for more information)
• Validity (years): Set the length of time in years that your key will be
valid. Your key should be valid for at least 25 years, so you can sign
app updates with the same key through the lifespan of your app.
• Certificate: Enter some information about yourself for your
certificate. This information is not displayed in your app, but is
included in your certificate as part of the APK.
7. Once you complete the form, click OK.
8. If you would like to build and sign your app with your upload key,
continue to the section about how to Sign your app with your upload
key. If you only want to generate the key and keystore, click Cancel.
186 | Page
Mobile Application Development (4350703)
If you already have an upload key, use it to sign your app. If instead your app
is already signed and published to the Google Play store with an existing app
signing key, use it to sign your app. You can later generate and register a
separate upload key with Google Play to sign and upload subsequent updates
to your app.
187 | Page
Mobile Application Development (4350703)
Figure: Generate a signed version of your app for the selected product flavors.
After Android Studio finishes building your signed app, you can
either locate or analyse your app by clicking on the appropriate option in the
pop-up notification, as shown in figure.
Figure: Click the link in the popup to analyse or locate your app bundle.
Now you’re ready to opt your app in to Play App Signing and upload your app
for release. If you’re new to the app publishing process, you may want to read
the Launch overview. Otherwise, continue to the page about how to Upload
your app to the Play Console.
188 | Page
Mobile Application Development (4350703)
Usually, it takes no more than two days to get approval from Google. Don’t
worry if you forget to add some information. You can edit your account later.
If you plan to sell paid apps or in-app purchases, you have to create a Google
Merchant Account. There you can manage app sales and your monthly
payouts, as well as analyse sales reports.
Once you finish creating the Merchant profile, the developer account gets
automatically linked to it.
189 | Page
Mobile Application Development (4350703)
Paperwork always requires much effort, especially when it comes to any kind
of legal documents. Based on our experience, we highly recommend starting
to prepare the End User License Agreement (EULA) and Privacy Policy in
advance.
You can take the documents from similar apps as references and create your
own based on them, or ask a lawyer to make everything from scratch.
Terms of Use or Terms and Conditions explain what services you offer the
users and how you expect them to behave in return. Though Google doesn’t
demand Terms of Use, it’s better to publish them. You can create one
document, adding there Privacy Policy and Terms of Use chapters.
Store listing:
Once you click on it a pop up will be shown as below where you have to
choose your Default language and Title of your app. Then click on the CREATE
button.
190 | Page
Mobile Application Development (4350703)
Add high-resolution icon images: you have to add the Hi-res icon of your
app.
191 | Page
Mobile Application Development (4350703)
Next thing you have to provide is the Feature Graphic of your app. Note that
this graphic is then used everywhere your app is featured on Google Play.
Then come to Contact details part, where you have to provide your Website
(if any), email, and Phone of yours.
192 | Page
Mobile Application Development (4350703)
Finally when you click on SAVE DRAFT button you can see that STORE
listing tab is now become turned to green and you are done for Store listing.
After redirecting to the next page click on the CREATE RELEASE button.
193 | Page
Mobile Application Development (4350703)
After that on the next page, you have to upload your APK file in Android App
Bundles and APKs to add section.
194 | Page
Mobile Application Development (4350703)
After that fill your email address as well as confirm the email address.
After selecting your app category make sure that you read all of these and
answer them correctly.
195 | Page
Mobile Application Development (4350703)
Once you saved all those things then click on CALCULATE RATING button.
When you redirected to another page scroll down and click on APPLY
RATING button. And you are done for Content rating section. Don’t forget to
notice that Content rating section is now become turned to green.
Then go to the Pricing & distribution section. Then select the country in which
you want to available your app.
196 | Page
Mobile Application Development (4350703)
Then go down and down and check out the Content guidelines and US export
laws section by marking them tick mark. Click on the SAVE DRAFT button.
Don’t forget to notice that Pricing & distribution section is now become
turned to green tick.
Then come to the App content section. And in the Privacy policy section click
on the Start button.
Then provide a valid Privacy policy URL. Note that google will check this.
197 | Page
Mobile Application Development (4350703)
Then select does your app contain ads or not? And click on SAVE button.
Then again go back and continue further steps by clicking start button
in Target audience and content section.
In the next page select the Target age group and scroll down and click on
the Next button.
198 | Page
Mobile Application Development (4350703)
Then check the Appeal to children section. And click on the Next button.
On the next page click on the Save button and you are done for App content
section.
Again go back to the App releases section. And in the Production track click
on the EDIT RELEASE button.
Then on the next page go down and down and click on the REVIEW button.
199 | Page
Mobile Application Development (4350703)
After usually 4 to 5 days they will review your app and let you know to either
approve or reject your app.
200 | Page