0% found this document useful (0 votes)
161 views541 pages

MAD Model Merged

The document is a sample question paper for a Mobile Application Development course, detailing the exam structure, instructions, and a variety of questions across different topics related to Android development. It includes sections on Android architecture, application lifecycle, UI components, and programming tasks, with marks allocated for each question. Additionally, it outlines the evaluation criteria for examiners to assess student responses based on understanding rather than exact wording.

Uploaded by

gavalimanasi1
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)
161 views541 pages

MAD Model Merged

The document is a sample question paper for a Mobile Application Development course, detailing the exam structure, instructions, and a variety of questions across different topics related to Android development. It includes sections on Android architecture, application lifecycle, UI components, and programming tasks, with marks allocated for each question. Additionally, it outlines the evaluation criteria for examiners to assess student responses based on understanding rather than exact wording.

Uploaded by

gavalimanasi1
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

Sample Question Paper:

Scheme – I
Programme Name: Computer/Information Technology Engineering
Programme code:CO/IF
Semester: VI Sem
22617
Course Title: Mobile Application Development
Marks : 70 Time: 3 Hrs.

Instructions:
(1) All questions are compulsory.
(2) Illustrate your answers with neat sketches wherever necessary.
(3) Figures to the right indicate full marks.
(4) Assume suitable data if necessary.
(5) Preferably, write the answers in sequential order.

Q.1) Attempt any FIVE of the following. (10 Marks)


a) List features of Anroid Operating System.
b) Define Android Virtual Devices (AVD).
c) Write the directory path where images are stored while developing Android
application.
d) List all attributes to develop a simple button .
e) Write the syntax for Intent-Filter tag.
f) Define services in Android operating system.
g) Enlist the steps to publish the Android application.

Q.2) Attempt any THREE of the following. (12 Marks)


a) Describe the Anroid architecture in detail.
b) Differentiate between JVM and DVM.
c) Explain the activity life cycle.
d) Discuss the need of permissions in Android. Describe the permissions to set system
functionalities like bluetooth,camera.

Q.3) Attempt any THREE of the following. (12 Marks)


a) Explore the Steps to install and configure Android Studio and SDK .
b) Explain Date and Time picker with its methods.
c) Describe the significance of SQLite database in Anroid.
d) Discuss Developer console with its purpose.

1
Q.4) Attempt any THREE of the following. (12 Marks)
a) Observe the following GUI and write an XML file using relative layout to create the
same.

b) Write a program to display circular progress bar.


c) List sensors in Android and explain any one in detail.
d) Explain zoom control (IN / OUT) with the help of an example.
e) Develop an application to send and receive SMS. (Write ONLY .java and permission
tag in manifest file)

Q.5) Attempt any TWO of the following. (12 Marks)


a) Develop the registration form using the following GUI.

b) Write a program to capture an image using camera and display it.


c) Develop a program to send an email.

2
Q.6) Attempt any TWO of the following. (12 Marks)
a) Develop an application to store student details like roll no, name, branch,
marks,percentage and retrieve student information using roll no. in SQLite databases.
b) Write a program to locate user’s current location. (Write ONLY .java and manifest
file)
c) Develop a simple calculator using table layout.

3
Sample Test Paper I

MSBTE Outcome based Curriculum


Scheme – I

Programme Name: Computer Engineering/Information Technology


Programme Code: CO/IF
Semester: Sixth 22617
Course: Mobile Application Development
Marks: 20 Time:1 hour
Instructions: All questions are compulsory
1. Illustrate your answers with neat sketches wherever necessary
2. Figures to the right indicate full marks
3. Assume suitable data if necessary
4. Preferably, write the answers in sequential order.

Q1. Attempt Any FOUR (08 Marks)


a) List all versions of android operating system.
b) Explain ADT Plugins in detail.
c) Define Emulator.
d) List Eight alignment attributes of relative layout.
e) Draw the hierarchical directory structure of android application.
f) Write features of android operating system.

Q2. Attempt any THREE (12 Marks)


a) Draw and explain android architecture in detail.
b) Differentiate JVM and DVM.
c) Write a program to display following output using suitable layout.

d) Explain any four UI Components of Android application.

4
Sample Test Paper II
MSBTE Outcome based Curriculum
Scheme – I

Programme Name: Computer Engineering/Information Technology


Programme Code: CO/IF
Semester: Sixth
22617
Course: Mobile Application Development
Marks: 20 Time:1 hour
Instructions: All questions are compulsory
1. Illustrate your answers with neat sketches wherever necessary
2. Figures to the right indicate full marks
3. Assume suitable data if necessary
4. Preferably, write the answers in sequential order

Q1. Attempt Any FOUR (08 Marks)


a) List different User Interface Elements. Explain Toggle Button.
b) Enlist different ways to handle databases in android? Elaborate any one.
c) Draw the life cycle of an activity.
d) List different types of views? Explain Scroll view.
e) Name any 4 methods to get location data in android.
f) Write steps to develop an android appication.

Q2. Attempt any THREE (12 Marks)


a) Build a GUI for Student table with 5 records, write queries to add, delete and view the
records from the SQLite databases.
b) Develop an android application to calculate age (Use Date Picker) using following GUI.

c) Define content provider and explain fragments.


d) Describe types of permisions used while developing android applications.

5
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
SUMMER – 2022 EXAMINATION
Subject Name: Mobile Application Development Model Answer Subject Code: 22617
Important Instructions to examiners: XXXXX
1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not applicable for
subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The figures
drawn by candidate and model answer may vary. The examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may vary and
there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based on
candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual (English +
Marathi) medium is introduced at first year of AICTE diploma Programme from academic year 2021-2022. Hence if
the students in first year (first and second semesters) write answers in Marathi or bilingual language (English
+Marathi), the Examiner shall consider the same and assess the answer based on matching of concepts with
model answer.

Q. Sub Answer Marking


No. Q. N. Scheme
Note: As Android programs contain many of the generated code statements from IDE,
while assessing such answers correct logical steps taken to obtain the required output
can be considered.

1 Attempt any FIVE of the following: 10 M

a) List any four features of Android operating system. 2M

Ans Features of Android Operating System: (Any four, ½


1)Storage M for one
2)Multitasking feature)
3)Web Browser
4)Open Source
5)Accessibility
6)Media Support
7)Streaming Media Support
8)Voice Based Features
9)Multitouch
10)External Storage
11)Video Calling
12)Handset Layout
13)Google cloud Messaging
14)WiFi Direct
b) Define Dalvik Virtual Machine (DVM). 2M

Page No: 1 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Dalvik Virtual Machine is a register-based machine that compiles byte code to get dex (Correct
code and that ensures that a device can run multiple instances efficiently. definition
2 M)
c) List any four folders from directory structure of Android project and 2M
elaborate in one line.
Ans Folders from directory structure: (List of
1)app: The App folder contains three subfolders (manifests, java and res) that make up names of any
our application. four folders :
They are divided so that it should be fairly easy to determine which resources go in which 1 M and
folder. elaboration
2)Manifest: This is where we would put our manifest files. Most Android apps have in one line
single manifest file. But an app may have several manifest files due to application
:1 M)
versioning, or for supporting specific hardware.
3)Java: This is the folder in our project where we will be storing all of the source code
files written in Java programming language.
4)res: It contains folders that help us to separate and sort the resources of our application.
Resources
basically mean all the needed files except the source code.
5)drawable: The drawable folder contains graphics that can be drawn to the screen.
6)layout: The layout folder contains XML files used for your layouts. These file are used
to set up the layout for your Activity and is used for basic alignment of your layouts,
components, widgets, and similar
resources that are used for the UI of your application.
7)mipmap : The mipmap folder contains the launcher icon files for the app. A launcher
icon is a graphic that
represents your app to users.
8)values: The values folder contains XML files that contain simple values, such as
strings, integers, and colors.
The values folder is used to keep track of the values we will be using in our application.

d) List any four attributes of check box. 2M

Ans 1)id (Any four


2)checked attribute, ½
3)gravity M for each)
4)text
5)text color
6)text size
7)text style
8)background
9)padding
e) Draw diagram of activity life cycle. 2M

Page No: 2 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans (2 M for
correct
diagram)

f) State syntax to display built in zoom control. 2M

Ans a) Built in Zoom control in Google map can be displayed with : Correct
Syntax : 2
UiSettings.setZoomControlsEnabled(true); M)
OR

b) In case, while display Google map by intent, default zoom level can be given in
the form of data as
geo:latitude,longitude?z=zoom
where lat and lag are for location and zoom level is to set initial zoom level which
Page No: 3 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
ranges from 0 to 21.

OR

c) In any normal activity, ZoomControl can be displayed as component by following


syntax :
ZoomControl zoomControls = (ZoomControls) findViewById(R.id.simpleZoomControl);
zoomControls.show()
g) Name two classes used to play audio and video in Android. 2M

Ans 1) MediaPlayer (Any two


class names
2) MediaController 1 M each)

3) AudioManager

2. Attempt any THREE of the following: 12 M

a) Describe Android architecture with diagram. 4M

Page No: 4 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Diagram: 2M
Explanation:
2M

1. Applications:

• The top layer of android architecture is Applications. The native and third party
applications like Contacts, Email, Music, Gallery, Clock, Games, etc. whatever we will
build those will be installed on this layer only.

• The application layer runs within the Android run time using the classes and services
made available from the application framework.

2. Application Framework:

• The Application Framework provides the classes used to create an Android application.
It also provides a generic abstraction for hardware access and manages the user interface

Page No: 5 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
and application resources.

• It basically provides the services through which we can create the particular class and
make that class helpful for the Applications creation.

• The application framework includes services like telephony service, location services,
notification. manager, NFC service, view system, etc. which we can use for application
development as per our requirements.

3. Android Runtime:

• Android Runtime environment is an important part of Android rather than an internal


part and it contains a components like core libraries and the Dalvik virtual machine.

• The Android run time is the engine that powers our applications along with the libraries
and it forms the basis for the application framework.

(i) Dalvik Virtual Machine (DVM) is a register-based virtual machine like Java Virtual
Machine (JVM).

It is specially designed and optimized for android to ensure that a device can run multiple

instances efficiently. It relies on the Linux kernel for threading and low-level memory

management.

(ii) The core libraries in android runtime will enable us to implement an android
applications using standard JAVA programming language.

4. Platform Libraries:

• The Platform Libraries includes various C/C++ core libraries and Java based libraries
such as SSL, libc, Graphics, SQLite, Webkit, Media, Surface Manger, OpenGL etc. to
provide a support for android development.

• Following are the summary details of some core android libraries available for android
development.

• Media library for playing and recording an audio and video formats

(i) The Surface manager library to provide a display management

(ii) SGL and OpenGL Graphics libraries for 2D and 3D graphics

(iii) SQLite is for database support and FreeType for font support

(iv) Web-Kit for web browser support and SSL for Internet security.

5. Linux Kernel:

Page No: 6 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• Linux Kernel is a bottom layer and heart of the android architecture. It is heart of
Android

architecture that exists at the root of android architecture and contains all the low-level
device

drivers for the various hardware components of an Android device.

• Linux Kernel is responsible fro device drivers, power management, memory


management, device management and resource access. It manage all the drivers such as
display drivers, camera drivers,

Bluetooth drivers, audio drivers, memory drivers, etc. which are mainly required for the
android device during the runtime.

• The Linux Kernel will provides an abstraction layer between the device hardware and
the remainder of the stack. It is responsible for memory management, power
management, device management, resource access, etc.

b) Differentiate between DVM and JVM. 4M

Ans Any 4 points


of
DVM (Dalvik Virtual Machine) JVM (Java Virtual Machine) differences :
It is Register based which is designed to run It is Stack based. 1 M each
on low memory.
DVM uses its own byte code and runs the JVM uses java byte code and runs
“.Dex” file. From Android 2.2 SDK Dalvik “.class” file having JIT (Just In Time).
has got a Just in Time compiler
DVM has been designed so that a device A single instance of JVM is shared
can run multiple instances of the VM with multiple applications.
efficiently. Applications are given their own
instance.
DVM supports the Android operating JVM supports multiple operating
system only. systems.
There is a constant pool for every It has a constant pool for every class.
application.
Here the executable is APK. Here the executable is JAR.

c) List and elaborate steps to deploy an Android application on Google play 4M


store.

Ans Steps to deploy and Android Application on Google Play Store: (List 1 M
and
Step 1: Make a Developer Account Elaboration 3
Step 2: Plan to Sell? Link Your Merchant Account M)
Step 3: Create an App
Step 4: Prepare Store Listing

Page No: 7 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Step 5: Upload APK to an App Release
Step 6: Provide an Appropriate Content Rating
Step 7: Set Up Pricing & Distribution
Step 8: Rollout Release to Publish Your App

Step 1: Create a Developer Account


Before you can publish any app on Google Play, you need to create a Developer Account.
You can easily sign up for one using your existing Google Account. You’ll need to pay a
one-time registration fee of $25 using your international credit or debit card. It can take
up to 48 hours for your registration to be fully processed.

Step 2: Plan to Sell? Link Your Merchant Account


If you want to publish a paid app or plan to sell in-app purchases, you need to create a
payments center profile, i.e. a merchant account. A merchant account will let you manage
your app sales and monthly payouts, as well as analyze your sales reports right in your
Play Console.

Step 3: Create an App


Now you have create an application by clicking on 'Create Application'. Here you have
to select your app’s default language from the drop-down menu and then type in a title
for your app. The title of your app will show on Google Play after you’ve published.

Step 4: Prepare Store Listing


Before you can publish your app, you need to prepare its store listing. These are all the
details that will show up to customers on your app’s listing on Google Play. You not
necessarily complete it at once , you can always save a draft and revisit it later when
you’re ready to publish.
The information required for your store listing is divided into several categories such as
Product Details containing title, short and full description of the app, Your app’s title
and description should be written with a great user experience in mind. Use the right
keywords, but don’t overdo it. Make sure your app doesn’t come across as spam-y or
promotional, or it will risk getting suspended on the Play Store.
Graphic Assets where you can add screenshots, images, videos, promotional graphics,
and icons that showcase your app’s features and functionality.
Languages & Translations, Categorization where in category can be selected to which
your app belong to. Contact Details , Privacy Policy for apps that request access to
sensitive user data or permissions, you need to enter a comprehensive privacy policy that
effectively discloses how your app collects, uses, and shares that data.

Step 5: Upload APK to an App Release


Finally upload your app, by uploading APK file. Before you upload APK, you need to
create an app release. You need to select the type of release you want to upload your first
app version to. You can choose between an internal test, a closed test, an open test, and a
production release. The first three releases allow you to test out your app among a select
Page No: 8 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
group of users before you make it go live for everyone to access.
This is a safer option because you can analyze the test results and optimize or fix your
app accordingly if you need to before rolling it out to all users.
Once you create a production release, your uploaded app version will become accessible
to everyone in the countries you choose to distribute it in and click on ‘Create release.’

Step 6: Provide an Appropriate Content Rating


If you don’t assign a rating to your app, it will be listed as ‘Unrated’. Apps that are
‘Unrated’ may get removed from Google Play.
To rate your app, you need to fill out a content rating questionnaire An appropriate
content rating will also help you get to the right audience, which will eventually improve
your engagement rates.

Step 7: Set Up Pricing & Distribution


Before you can fill out the details required in this step, you need to determine your app’s
monetization strategy. Once you know how your app is going to make money, you can go
ahead and set up your app as free or paid.
You can always change your app from paid to free later, but you cannot change a free app
to paid. For that, you’ll need to create a new app and set its price.

Step 8: Rollout Release to Publish Your App


The final step involves reviewing and rolling out your release after making sure you’ve
taken care of everything else.
Before you review and rollout your release, make sure the store listing, content rating,
and pricing and distribution sections of your app each have a green check mark next to
them.
Once you’re sure about the correctness of the details, select your app and navigate to
‘Release management’ – ‘App releases.’ You can always opt for reviews by clicking on
‘Review’ to be taken to the ‘Review and rollout release’ screen. Here, you can see if there
are any issues or warnings you might have missed out on.
Finally, select ‘Confirm rollout.’ This will also publish your app to all users in your target
countries on Google Play.
d) Describe with example, how to create a simple database in SQLite (Assume 4M
suitable data).
(Note : Any other method such as creating subclass of SQLiteOpenHelper class
and overriding and using required methods with relevant example can also be
considered)
Ans This procedure is by openOrCreateDatabase() Description 1
1. The package imported into the application is android.database.sqlite.SQLiteDatabase. M, 1 M for
2. Here the class used is SQLiteDatabase. XML file , 2
3. The method used to create the database or connect to the database is M for Java
openOrCreateDatabse() method. File)
Program:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
Page No: 9 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:text="Create SQLite Database"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:id="@+id/button" />
</RelativeLayout>

MainActivity.java

package in.edu.vpt.insertusingasync;
import android.app.ProgressDialog;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;;

public class MainActivity extends AppCompatActivity {


SQLiteDatabase sqLiteDatabaseObj;
Button EnterData;

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

createData = (Button)findViewById(R.id.button);
createData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sqLiteDatabaseObj = openOrCreateDatabase("AndroidJSonDataBase",
Context.MODE_PRIVATE, null);
} });
}

3. Attempt any THREE of the following: 12 M

a) Write down the steps to install and configure Android studio. 4M

Ans Step 1: Go to https://developer.android.com/android-studio/download to get the Android (4 M for


Studio executable or zip file. appropriate
Page No: 10 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Step 2: steps)
● Click on the Download Android Studio Button.
● Click on the “I have read and agree with the above terms and conditions”
checkbox followed by the download button
● Click on the Save file button in the appeared prompt box and the file will start
downloading.
Step 3: After the downloading has finished, open the file from downloads and will
prompt the following dialog box. Click on next. In the next prompt, it’ll ask for a path for
installation. Choose a path and hit next.
Step 4: It will start the installation, and once it is completed, it will be like the image
shown below.
Step 5: Once “Finish” is clicked, it will ask whether the previous settings need to be
imported [if the android studio had been installed earlier], or not. It is better to choose the
‘Don’t import Settings option’. Click the OK button.
Step 6: This will start the Android Studio. Meanwhile, it will be finding the available
SDK components.
Step 7: After it has found the SDK components, it will redirect to the Welcome dialog
box.
Choose Standard and click on Next. Now choose the theme, whether the Light theme or
the Dark one. The light one is called the IntelliJ theme whereas the dark theme is
called Darcula. Choose as required. Click on the Next button.
Step 8: Now it is time to download the SDK components. Click on Finish. Components
begin to download let it complete. The Android Studio has been successfully
configured. Now it’s time to launch and build apps. Click on the Finish button to launch
it.
Step 9: Click on Start a new Android Studio project to build a new app.

b) State syntax to create Text View and Image button with any two attributes of each. 4M

Ans Text View: (Syntax of


Syntax : TextView
<TextView and
android:id="@+id/textView1" ImageButton
android:layout_width="<width value>” : 1 M each
android:layout_height="<height_value>" Any two
android:text="<text to be displayed>"/> appropriate
Attributes/Properties of TextView: attributes of
● id: Supply an identifier name of this view, to later retrieve it with each : 1/2 M
View.findViewByID() or Activity.findViewById() each)
● alpha: alpha property of the view as a value between 0 (entirely transparent) and
1(Completely Opaque). [flag]
● auto link: Controls whether links such as urls and email addresses are
automatically found and converted to clickable links.[flag]
● gravity: The gravity attribute is an optional attribute which is used to control the
alignment of the text like left, right, center, top, bottom, center_vertical,
center_horizontal etc
● text: text attribute is used to set the text in a text view. We can set the text in xml as
Page No: 11 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
well as in the java class.
● textColor: textColor attribute is used to set the text color of a text view. Color
value is in the form of “#argb”, “#rgb”, “#rrggbb”, or “#aarrggbb”.
● textSize: textSize attribute is used to set the size of text of a text view. We can set
the text size in sp(scale independent pixel) or dp(density pixel).
● textStyle: textStyle attribute is used to set the text style of a text view. The possible
text styles are bold, italic and normal. If we need to use two or more styles for a text
view then “|” operator is used for that.
● background: background attribute is used to set the background of a text view. We
can set a color or a drawable in the background of a text view.
● padding: padding attribute is used to set the padding from left, right, top or bottom.
In above example code of background we also set the 10dp padding from all the
sides of text view.

ImageButton:
Syntax :
<ImageButton
android:id="@+id/imageButton"
android:layout_width="<width value>"
android:layout_height="<height value>"
app:srcCompat="<image source from drawable folder "/>
Attributes/Properties of ImageButton:

● id: id is an attribute used to uniquely identify a image button. Below is the


example code in which we set the id of a image button.
● src: src is an attribute used to set a source file of image or you can say image in
your image button to make your layout look attractive.
● background: background attribute is used to set the background of an image
button. We can set a color or a drawable in the background of a Button.
● padding: padding attribute is used to set the padding from left, right, top or
bottom of the ImageButton.

c) Describe Android service life cycle along with diagram. 4M

Ans ● A service is an application component which runs without direst interaction with (Explanation
the user in the background. 2 M,
● Services are used for repetitive and potentially long running operations, i.e., Diagram
Internet downloads, checking for new data, data processing, updating content 2M)
providers and the like.
● Service can either be started or bound we just need to call either startService() or
bindService() from any of our android components. Based on how our service
was started it will either be “started” or “bound”

Page No: 12 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Service Lifecycle
1. Started
a. A service is started when an application component, such as an activity,
starts it by calling startService().
b. Now the service can run in the background indefinitely, even if the
component that started it is destroyed.
2. Bound
a. A service is bound when an application component binds to it by calling
bindService().
b. A bound service offers a client-server interface that allows components to
interact with the service, send requests, get results, and even do so across
processes with InterProcess Communication (IPC).
c. Like any other components service also has callback methods. These will
be invoked while the service is running to inform the application of its
state. Implementing these in our custom service would help you in
performing the right operation in the right state. •
d. There is always only a single instance of service running in the app. If you
are calling startService() for a single service multiple times in our

Page No: 13 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
application it just invokes the onStartCommand() on that service. Neither
is the service restarted multiple times nor are its multiple instances created
1. onCreate():
This is the first callback which will be invoked when any component starts the
service. If the same service is called again while it is still running this method
wont be invoked. Ideally one time setup and intializing should be done in this
callback.
2. onStartCommand() /startSetvice()
This callback is invoked when service is started by any component by calling
startService(). It basically indicates that the service has started and can now run
indefinetly.
3. onBind()
To provide binding for a service, you must implement the onBind() callback
method. This method returns an IBinder object that defines the programming
interface that clients can use to interact with the service.
4. onUnbind()
This is invoked when all the clients are disconnected from the service.
5. onRebind()
This is invoked when new clients are connected to the service. It is called after
onRebind
6. onDestroy()
This is a final clean up call from the system. This is invoked just before the
service is being destroyed.

d) State and elaborate the syntax of required class and methods for 4M
Geocoding.
Ans Geocoder: (2 M for
explanation
A class for handling geocoding and reverse geocoding.
and syntax of
Geocoding is the process of transforming a street address or other description of a class, 2 M
location into a (latitude, longitude) coordinate. for
explanation
Reverse geocoding is the process of transforming a (latitude, longitude) coordinate into a and syntax of
(partial) address. The amount of detail in a reverse geocoded location description may any two
vary, for example one might contain the full street address of the closest building, while methods)
another might contain only a city name and postal code.

The Geocoder class requires a backend service that is not included in the core android
framework.

The Geocoder query methods will return an empty list if there no backend service in the
platform. Use the isPresent() method to determine whether a Geocoder implementation
exists.

Page No: 14 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Syntax
Geocoder (Context context)

Constructs a Geocoder localized for the default locale.

Geocoder(Context context, Locale locale)

Constructs a Geocoder localized for the given locale.

Methods with Syntax


a. getFromLocation

Syntax

public List<Address> getFromLocation (double latitude, double longitude, int


maxResults)

public void getFromLocation (double latitude, double longitude, int maxResults,


Geocoder.GeocodeListener listener)

This method returns an array of Addresses that attempt to describe the area immediately
surrounding the given latitude and longitude. The returned addresses should be localized
for the locale provided to this class's constructor.

b. getFromLocationName
Syntax :

● public List<Address> getFromLocationName (String locationName, int


maxResults, double lowerLeftLatitude, double lowerLeftLongitude, double
upperRightLatitude, double upperRightLongitude)
● public void getFromLocationName (String locationName, int maxResults,
double lowerLeftLatitude, double lowerLeftLongitude, double
upperRightLatitude, double upperRightLongitude, Geocoder.GeocodeListener
listener)
● public void getFromLocationName (String locationName, int maxResults,
Geocoder.GeocodeListener listener)
● public List<Address> getFromLocationName (String locationName, int
maxResults)

Returns an array of Addresses that attempt to describe the named location, which may be
a place name such as "Dalvik, Iceland", an address such as "1600 Amphitheatre Parkway,
Mountain View, CA", an airport code such as "SFO", and so forth. The returned
addresses should be localized for the locale provided to this class's constructor.

c. isPresent

Syntax

Page No: 15 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

public static boolean isPresent ()

Returns true if there is a geocoder implementation present that may return results. If true,
there is still no guarantee that any individual geocoding attempt will succeed.

4. Attempt any THREE of the following: 12 M

a) Explain with example, code to create GUI using absolute layout (Assume 4M
suitable data).

Ans ● AbsoluteLayout is based on the simple idea of placing each control at an absolute (Explanation
position. We specify the exact x and y coordinates on the screen for each control. 2 M,
This is not recommended for most UI development (in fact AbsoluteLayout is Example 2
currently deprecated) since absolutely positioning every element on the screen makes M)
an inflexible UI that is much more difficult to maintain.

Absolute Layout
● An Absolute Layout lets you specify exact locations (x/y coordinates) of its children.
Absolute layouts are less flexible and harder to maintain than other types of layouts
without absolute positioning. AbsoluteLayout is based on the simple idea of placing
each control at an absolute position.
● We specify for the exact x and y corodinates on the screen for every control. So this
recommended for most UI development (in fact Absolute Layout is currentaly
deprecated)since absolute positioning of every element on the screen makes an
inflexible UI that is much more difficult to maintain.
● Consider what happens if a control needs to be added to the user interface UI, we
would have to change the position of every single element that is shifted by the new
control. This allows child views to be positioned at specified X and Y coordinates
within the containing layout view.

Example
(Note :Any other relevant example using absoluteLayout can be considered, No java
code is expected)

Page No: 16 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
activity_main.xml

<AbsoluteLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_x="110px"
android:layout_y="110px"
android:text="User Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_x="250px"
android:layout_y="80px"
android:width="100px"
android:layout_width="200dp"
android:layout_height="wrap_content" />
<TextView
android:layout_x="110px"
android:layout_y="200px"
android:text="Password"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_x="250px"
android:layout_y="150px"
android:width="100px"
android:layout_width="200dp"
android:layout_height="wrap_content" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Log In"
android:layout_x="300px"
android:layout_y="300px"/>
</AbsoluteLayout>

b) Write a program to demonstrate Date and Time picker. 4M


(Note: Consider the appropriate XML file. All attributes are not required.
In java file all imports are not expected. Different relevant logic/code can be
considered.)
Ans activity_main.xml (2M for
<?xml version="1.0" encoding="utf-8"?> correct use
<androidx.constraintlayout.widget.ConstraintLayout of Date
xmlns:android="http://schemas.android.com/apk/res/android" picker
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" 2M for
android:layout_width="match_parent"
Page No: 17 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="match_parent" correct use
tools:context=".MainActivity"> of
TimePicker)
<TextView
android:id="@+id/tvDate"
android:layout_width="149dp"
android:layout_height="46dp"
android:layout_marginEnd="224dp"
android:layout_marginBottom="312dp"
android:textSize="20dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<Button
android:id="@+id/btnDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="96dp"
android:layout_marginBottom="312dp"
android:text="Set Date"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:ignore="DuplicateClickableBoundsCheck" />

<DatePicker
android:id="@+id/dtpcker"
android:layout_width="314dp"
android:layout_height="293dp"
android:layout_marginBottom="368dp"
android:datePickerMode="spinner"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.36"
app:layout_constraintStart_toStartOf="parent" />

<TimePicker
android:id="@+id/timepcker"
android:layout_width="184dp"
android:layout_height="195dp"
android:layout_marginEnd="132dp"
android:layout_marginBottom="108dp"
android:timePickerMode="spinner"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<TextView
android:id="@+id/tvTime"
android:layout_width="130dp"
Page No: 18 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="56dp"
android:layout_marginEnd="232dp"
android:layout_marginBottom="40dp"
android:textSize="20dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<Button
android:id="@+id/btnTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="104dp"
android:layout_marginBottom="48dp"
android:text="Set Time"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java
package com.example.datepickereg;
import androidx.appcompat.app.AppCompatActivity;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.TimePicker;
import java.util.Calendar;

public class MainActivity extends AppCompatActivity {


TextView tvDate,tvTime;
DatePicker dtpcker;
TimePicker timepcker;
Button b1,b2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tvDate=findViewById(R.id.tvDate);
tvTime=findViewById(R.id.tvTime);
b1=findViewById(R.id.btnDate);
b2=findViewById(R.id.btnTime);
dtpcker=findViewById(R.id.dtpcker);
timepcker=findViewById(R.id.timepcker);
b1.setOnClickListener(new View.OnClickListener() {
@Override
Page No: 19 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
public void onClick(View view) {
tvDate.setText("Date : "+dtpcker.getDayOfMonth()+"-
"+dtpcker.getMonth()+"-"+dtpcker.getYear());
}
});
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

tvTime.setText(timepcker.getCurrentHour()+":"+timepcker.getCurrentMinute());
}
});
}
}
c) Describe multimedia framework of Android with diagram. 4M

Ans ● The android multimedia system includes multimedia applications, multimedia (Explanation
frameworks, OpenCore engine and hardware abstract for audio/video input/output 2M,
devices. And the goal of the android multimedia framework is to provide a
reliable interface for java services. The multimedia framework consists of several Diagram 2
core dynamic libraries such as libmediajni, libmedia, libmediaplayservice and so M)
on.
● Java classes call the Native C library Libmedia through Java JNI(Java Native
Interface). Libmedia library communications with Media Server guard process
through Android’s Binder IPc (inter process communication) mechanism.
● Media Server process creates the corresponding multimedia service according to
the Java multimedia applications.
● The whole communication between Libmedia and Media Server forms a
Client/Server model

Android Multimedia Framework Architecture

Page No: 20 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
● Typical video/audio data stream works in Android as follows. Particularly, Java
applications first set the URI of the media (from file or network) to PVPlayer
through Java framework, JNI and Native C. In this process, there are no data
stream flows.
● Then PVPlayer processes the media data stream with the steps: demux the media
data to separate video/audio data stream, decode video/audio data, sync
video.audio time, send the decoded data out.
● The below is the description of media codec/format, container and network
protocol supported by the Android platform.
1. Container: The audio file format is a file for storing digital audio data on
a system. This data can be manipulated to reduce the size or change the
quality of the audio. It is a kind of container to store audio information.
2. Audio Format: Any format or codec can be used including the ones
provided by Android or those which are specific devices. However it is
recommended to use the specified file formats as per devices.
3. Network Protocol: Protocols such as RTSP, HTTP,HTTPS are supported
in audio and video playback.

d) Discuss developer console with at least four features 4M

Ans ● Google Play Developer Console is the platform that Google provides for Google (Any 4
Play and Android developers to publish their apps. relevant
● The Google Play Developer console allows app developers and marketers to features 1M
better understand how their apps are performing in terms of growth, technical each )
performance such as crashes or display issues, and financials.
● The console offers acquisition reports and detailed analysis which can help app
devs find out how well an app is really performing.
● The platform is important as it provides developers with access to first party data
(trustworthy information collected about an app’s audience that comes straight
from Google Play) that highlights the real performance of an app.
● It shows the number of impressions an app listing receives and the number of
Installs an app receives from different sources over time.

e) Write a program to demonstrate declaring and using permissions with any 4M


relevant example.
Ans Permission declaring : 4 M for any
correct
The permissions are declared in AndroidManifest.xml file under Manifest folder. program
Permission can be set by <uses-permission> tag in AndroidManifest.xml.
demonstratin
Example:
Following example is to send SMS. g declaration
(Note: Any other relevant example which uses permissions can be considered) and use of
permissions
AndroidManifest.xml

Page No: 21 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<uses-permission android:name="android.permission.SEND_SMS"/>

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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"
tools:context=".MainActivity">

<TextView
android:id="@+id/textView"
android:layout_width="81dp"
android:layout_height="41dp"
android:layout_marginEnd="268dp"
android:layout_marginBottom="576dp"
android:text="To :"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

<TextView
android:id="@+id/textView2"
android:layout_width="70dp"
android:layout_height="43dp"
android:layout_marginEnd="276dp"
android:layout_marginBottom="512dp"
android:text="Sms Text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<EditText
android:id="@+id/etPhno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="40dp"
android:layout_marginBottom="572dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<EditText
android:id="@+id/etmsg"
android:layout_width="193dp"
android:layout_height="51dp"
android:layout_marginEnd="56dp"
android:layout_marginBottom="504dp"
Page No: 22 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:ignore="SpeakableTextPresentCheck" />

<Button
android:id="@+id/btnSms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="156dp"
android:layout_marginBottom="400dp"
android:text="SEND SMS"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java
package com.example.testreceivesms;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


EditText et1,et2;
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1=findViewById(R.id.etPhno);
et2=findViewById(R.id.etmsg);
b1=findViewById(R.id.btnSms);
if(ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.SEN
D_SMS)!=
PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(MainActivity.this,new
String[]{Manifest.permission.SEND_SMS},100);
}
b1.setOnClickListener(new View.OnClickListener() {
Page No: 23 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
@Override
public void onClick(View v) {
try {
String phno= et1.getText().toString();
String msg=et2.getText().toString();
SmsManager smsManager= SmsManager.getDefault();
smsManager.sendTextMessage(phno,null,msg,null,null);
Toast.makeText(MainActivity.this,"Sms sent successfully",
Toast.LENGTH_LONG).show();
}
catch(Exception e)
{
Toast.makeText(MainActivity.this,"Sms failed to send... try again",
Toast.LENGTH_LONG).show();
}
}
});
}
}
5. Attempt any TWO of the following: 12 M

a) Write a program to convert temperature from celcius to farenhite and vice versa 6M
using Toggle button. (Design UI as per your choice. Write XML and java file)
(Note: Consider the appropriate XML file. All attributes are not required.
In java file all imports are not expected. Different relevant logic/code can be
considered.)
Ans activity_main.xml XML file:
<?xml version="1.0" encoding="utf-8"?> 2M
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
Java Code:
android:layout_width="match_parent"
4M
android:layout_height="match_parent"
tools:context=".MainActivity">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edittext"
android:hint="Enter the temp"/>

<ToggleButton
android:id="@+id/togglebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/edittext"
android:layout_marginTop="35dp"
android:textOff="F to C"
android:textOn="C to F" />
Page No: 24 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/togglebutton"
android:layout_marginTop="56dp" />
</RelativeLayout>
MainActivity.java
package com.example.p1;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.ToggleButton;

public class MainActivity extends AppCompatActivity {


Button b1;
EditText et;
ToggleButton tb;
Double a;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et=findViewById(R.id.edittext);
b1=findViewById(R.id.button);
tb=findViewById(R.id.togglebutton);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(tb.isChecked())
{
a=Double.parseDouble(String.valueOf(et.getText()));
Double b=a*9/5+32;
String r=String.valueOf(b);
Toast.makeText(MainActivity.this,r+"°F",Toast.LENGTH_SHORT).show();
}
else
{
a=Double.parseDouble(String.valueOf(et.getText()));
Double b=a-32;
Double c=b*5/9;
String r=String.valueOf(c);

Toast.makeText(MainActivity.this,r+"°C",Toast.LENGTH_SHORT).show();
}
Page No: 25 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}
});
}
}

b) Write a program to capture an image using camera and display it. 6M


(Note: Consider the appropriate XML file. All attributes are not required.
In java file all imports are not expected. Different relevant logic/code can be
considered.)
Ans activity_main.xml XML file:
2M
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" Java Code:
android:layout_width="match_parent" 4M
android:layout_height="match_parent"
android:padding="40dp"
android:orientation="horizontal"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CAMERA"
android:id="@+id/text"
android:textSize="20dp"
android:gravity="center"/>

<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text"
android:layout_marginTop="81dp"
android:src="@drawable/rose"/>

<Button
android:id="@+id/photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/image"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="TAKE PHOTO" />

</RelativeLayout>

Page No: 26 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

MainActivity.java

package com.example.ifcdiv;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {


Button b1;
ImageView imageView;
int CAMERA_REQUEST=1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

b1=findViewById(R.id.photo);
imageView=findViewById(R.id.image);

b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Intent i=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);


startActivityForResult(i,CAMERA_REQUEST);
}
});
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent
data) {
super.onActivityResult(requestCode, resultCode, data);

if (requestCode==CAMERA_REQUEST)
{
Bitmap image= (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(image);
}
}
}

Page No: 27 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
c) Develop and application to send and receive SMS (Design minimal UI as per 6M
your choice. Write XML, java and manifest file)
(Note: Consider appropriate XML file. All attributes are not required. In java
file all imports are not expected. Different relevant login/code can be considered.
Statements showing permissions can be written under AndroidManifest.xml)
Ans Permissions and <receiver> tag required in AndroidManifest.xml XML file:
<uses-permission android:name="android.permission.RECEIVE_SMS" /> 1M
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/> Manifest
<uses-permission android:name="android.permission.WRITE_SMS"/> File:1M
Java Code:
<receiver
4M
android:name=".SmsReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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"
tools:context=".MainActivity">

<TextView
android:id="@+id/textView"
android:layout_width="81dp"
android:layout_height="41dp"
android:layout_marginEnd="268dp"
android:layout_marginBottom="576dp"
android:text="To :"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>

<TextView
android:id="@+id/textView2"
android:layout_width="70dp"
android:layout_height="43dp"
android:layout_marginEnd="276dp"
android:layout_marginBottom="512dp"
android:text="Sms Text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
Page No: 28 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

<EditText
android:id="@+id/etPhno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="40dp"
android:layout_marginBottom="572dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />

<EditText
android:id="@+id/etmsg"
android:layout_width="193dp"
android:layout_height="51dp"
android:layout_marginEnd="56dp"
android:layout_marginBottom="504dp"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:ignore="SpeakableTextPresentCheck" />

<Button
android:id="@+id/btnSms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="156dp"
android:layout_marginBottom="400dp"
android:text="SEND SMS"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java
package com.example.testreceivesms;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

Page No: 29 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
public class MainActivity extends AppCompatActivity {
SmsReceiver sms= new SmsReceiver();
EditText et1,et2;
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1=findViewById(R.id.etPhno);
et2=findViewById(R.id.etmsg);
b1=findViewById(R.id.btnSms);
if(ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.SEN
D_SMS)!=
PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(MainActivity.this,new
String[]{Manifest.permission.SEND_SMS},100);
}
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
String phno= et1.getText().toString();
String msg=et2.getText().toString();
SmsManager smsManager= SmsManager.getDefault();
smsManager.sendTextMessage(phno,null,msg,null,null);
Toast.makeText(MainActivity.this,"Sms sent successfully",
Toast.LENGTH_LONG).show();
}
catch(Exception e)
{
Toast.makeText(MainActivity.this,"Sms failed to send... try again",
Toast.LENGTH_LONG).show();
}
}
});
}
@Override
protected void onStart() {
super.onStart();
IntentFilter filter=new
IntentFilter("android.provider.Telephony.SMS_RECEIVED");
registerReceiver(sms,filter);
}

@Override
protected void onStop() {
super.onStop();
unregisterReceiver(sms);
Page No: 30 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}
}

SmsReceiver.java
package com.example.testreceivesms;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.widget.Toast;

public class SmsReceiver extends BroadcastReceiver {


SmsReceiver(){}
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();

if (bundle != null) {
// Retrieve the SMS Messages received
Object[] sms = (Object[]) bundle.get("pdus");

// For every SMS message received


for (int i=0; i < sms.length; i++) {
// Convert Object array
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i]);

String phone = smsMessage.getOriginatingAddress();


String message = smsMessage.getMessageBody().toString();

Toast.makeText(context, “Received from “+ phone + ": " + message,


Toast.LENGTH_SHORT).show();
}
}
}
}

6. Attempt any TWO of the following: 12 M

a) Write a program to implement Android Activity Life Cycle. Use toast messages 6M
to display message through life cycle.
(Note: No XML code is required. In java file all imports are not expected.)
Ans package com.example.p1; Use of any 6
import androidx.appcompat.app.AppCompatActivity; methods of
import android.os.Bundle; Activity life
import android.widget.Toast; cycle : 1 M
public class MainActivity extends AppCompatActivity { each
@Override
Page No: 31 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(getApplicationContext(),"Activity
created",Toast.LENGTH_LONG).show();
}

@Override
protected void onStart() {
super.onStart();
Toast.makeText(getApplicationContext(),"Activity
Started",Toast.LENGTH_LONG).show();
}

@Override
protected void onStop() {
super.onStop();
Toast.makeText(getApplicationContext(),"Activity
Stop",Toast.LENGTH_LONG).show();
}

@Override
protected void onDestroy() {
super.onDestroy();
Toast.makeText(getApplicationContext(),"Activity
Destroy",Toast.LENGTH_LONG).show();
}

@Override
protected void onPause() {
super.onPause();
Toast.makeText(getApplicationContext(),"Activity
Pause",Toast.LENGTH_LONG).show();
}
@Override
protected void onRestart() {
super.onResume();
Toast.makeText(getApplicationContext(),"Activity
Restart",Toast.LENGTH_LONG).show();

@Override
protected void onResume() {
super.onResume();
Toast.makeText(getApplicationContext(),"Activity
Resume",Toast.LENGTH_LONG).show();
}
}
b) Develop an application to display Google map with user's current location. 6M
(Note : Consider the appropriate XML file. All attributes are not required.
Page No: 32 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
In java file all imports are not expected. Different relevant logic/code can be
considered.)
Ans act ivity_main.xml XML file:
<?xml version="1.0" encoding="utf-8"?> 1M
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" Java Code:
android:layout_width="match_parent" 5M
android:layout_height="match_parent"
tools:context=".MainActivity">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/google_map"
android:name="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>

MainActivity.Java

package com.example.location;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.FragmentActivity;
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import android.widget.Toast;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;

public class MainActivity extends FragmentActivity implements OnMapReadyCallback


{
Location currentlocation;
Page No: 33 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
FusedLocationProviderClient fusedLocationProviderClient;
private static final int REQUEST_CODE = 101;

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

fusedLocationProviderClient =
LocationServices.getFusedLocationProviderClient(this);
fetchLastLocation();
}

private void fetchLastLocation() {

if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,new
String[]{Manifest.permission.ACCESS_FINE_LOCATION},REQUEST_CODE);
return;
}
Task<Location> task = fusedLocationProviderClient.getLastLocation();
task.addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
if(location!=null)
{
currentlocation=location;

Toast.makeText(getApplicationContext(),currentlocation.getLatitude()+""+current
location.getLongitude(), Toast.LENGTH_SHORT).show();
SupportMapFragment supportMapFragment =
(SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.go
ogle_map);
supportMapFragment.getMapAsync(MainActivity.this);
}
}
});
}
Page No: 34 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
@Override
public void onMapReady(@NonNull GoogleMap googleMap) {
LatLng latLng=new
LatLng(currentlocation.getLatitude(),currentlocation.getLongitude());
MarkerOptions markerOptions=new MarkerOptions().position(latLng)
.title("I am Here");
googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng,5));
googleMap.addMarker(markerOptions);

}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[]
permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case REQUEST_CODE:
if (grantResults.length > 0 && grantResults[0] ==
PackageManager.PERMISSION_GRANTED) {
fetchLastLocation();
}
break;
}
}
}
c) Design UI using table layout to display buttons with 0 9 numbers on it. Even display 6M
submit and clear button. When user clicks on particular buttons and later when
clicks on submit button, it should display the numbers clicked.
(Note: Consider the appropriate XML file. All attributes are not required.
In java file all imports are not expected. Different relevant logic/code can be
considered.)
Ans activity_main.xml XML file:
<?xml version="1.0" encoding="utf-8"?> 3M
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
Java Code:
android:layout_width="match_parent"
3M
android:layout_height="match_parent"
android:stretchColumns="*"
tools:context=".MainActivity">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Button
Page No: 35 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/button0"
android:text="0"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/button1"
android:text="1"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button2"
android:text="2" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/button3"
android:text="3"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/button4"
android:text="4"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:id="@+id/button5"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="6"
android:id="@+id/button6"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="7"
Page No: 36 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:id="@+id/button7"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
android:id="@+id/button8"/>

</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="9"
android:id="@+id/button9"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Submit"
android:id="@+id/submit"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Clear"
android:id="@+id/clear"/>
</TableRow>
</TableLayout>
(Java File)
package com.example.p1;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


Button button0, button1, button2, button3, button4, button5, button6,button7,
button8, button9,submit,clear;
String a=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button0 = (Button) findViewById(R.id.button0);
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
Page No: 37 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
button3 = (Button) findViewById(R.id.button3);
button4 = (Button) findViewById(R.id.button4);
button5 = (Button) findViewById(R.id.button5);
button6 = (Button) findViewById(R.id.button6);
button7 = (Button) findViewById(R.id.button7);
button8 = (Button) findViewById(R.id.button8);
button9 = (Button) findViewById(R.id.button9);
submit=(Button) findViewById(R.id.submit);
clear=(Button) findViewById(R.id.clear);
button0.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

a=button0.getText().toString();
}
});
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

a=button1.getText().toString();
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

a=button2.getText().toString();
}
});
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

a=button3.getText().toString();
}
});
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

a=button4.getText().toString();
}
});
button5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

a=button5.getText().toString();
Page No: 38 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}
});
button6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

a=button6.getText().toString();
}
});
button7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a=button7.getText().toString();
}
});
button8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

a=button8.getText().toString();
}
});
button9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

a=button9.getText().toString();
}
});
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

Toast.makeText(getApplicationContext(),a,Toast.LENGTH_LONG).show(); }
});
}
}

Page No: 39 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER – 2022 EXAMINATION
Subject Name Mobile Application Development Model Answer Subject Code: 22617
Important Instructions to examiners: XXXXX
1) The answers should be examined by key words and not as word-to-word as given in the model answer
scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not
applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The
figures drawn by candidate and model answer may vary. The examiner may give credit for any equivalent
figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may
vary and there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based
on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual
(English + Marathi) medium is introduced at first year of AICTE diploma Programme from academic year
2021-2022. Hence if the students in first year (first and second semesters) write answers in Marathi or
bilingual language (English +Marathi), the Examiner shall consider the same and assess the answer based
on matching of concepts with model answer.

Q. Sub Note: As Android programs contain many of the auto generated code statements from IDE, Marking
No. Q. while assessing such answers correct logical steps taken to obtain the required output can be Scheme
N. considered.
Answer

1 Attempt any FIVE of the following: 10 M

a) Define OHA and state goal of OHA. 2M

Ans The OHA is the group that is in charge of the Android smartphones operating system. It was (Define : 1
created by Google. The Open Handset Alliance (OHA) is consortium of multiple companies M, Stating
like Samsung, Sony, Intel and many more to provide services and deploy handsets using goal 1 M)
android platform.
The Open Handset Alliance (OHA) is an association whose goal is to develop open standards
for mobile devices, promote innovation in mobile phones and provide a better experience for
consumers at a lower cost.

b) Define Android Virtual Devices (AVD). 2M

Ans An Android Virtual Device (AVD) is a configuration that defines the characteristics of an (Define : 2
Android phone, tablet, Wear OS, Android TV, or Automotive OS device that you want to M ,any valid
simulate in the Android Emulator. The AVD Manager is an interface you can launch from definition
Android Studio that helps you create and manage AVDs. should be
considered)

Page No: 1 | 41
for more study material visit www.diplomachakhazana.in
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
c) State how the APK files are built? 2M

Ans  The javac compiler compiles the java source file into the class file. (For each
 The dx tool takes all the class files of your application and generates a single .dex file which step 1/2 M)
is a platform specific tool.
 Then Android Assets Packaging Tool (aapt) handles the packaging process and finally
creates an executable file with extension .apk.
 An APK file contains all of a program's code (such as .dex files), resources, assets,
certificates, and manifest file.

d) Enlist the elements of UI. 2M

Ans Elements of UI. (1/2 mark


for each UI
 EditText element,
 TextView any 4 UI
elements
 ListView
expected)
 GridView
 ScrollView
 ImageView
 ToggleButton
 CheckBox
 RadioButton

OR
Components of UI
 Menu Bar
 Toolbar
 Navigation Bar
 Editor Tabs
 Editor
 Project Explorer
 Status Bar
 Tool Buttons
e) State the uses of Intent in Android. 2M

Ans An Intent is a messaging object you can use to request an action from another app component. (1 M for
Intents are used for facilitating communication between components like Activities, Services each use, 2
and Broadcast Receivers. uses
expected)

f) Name any four methods to get location data in android. 2M

Ans •float distanceTo(Location dest) (1/2 M for


•float getAccuracy() each
•float getBearing() method,
Page No: 2 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
•double getAltitude() any 4
•double getLatitude() methods
•float getSpeed() expected)
•boolean hasAccuracy()
•boolean hasAltitude()
•boolean hasBearing()
•boolean hasBearing()
•boolean hasSpeed()
•void reset()
•void setAccuracy(float accuracy)
•void setAltitude(double altitude)
g) Explain significance of content provider. 2M

Ans Content Providers are used to share data between two applications. This can be implemented (1 M for
in two ways: each
1. When you want to implement the existing content provider in another application. significance
2. When you want to create a new content provider that can share its data with other ,
Applications

2. Attempt any THREE of the following: 12 M

a) Describe the different features of Android. 4M

Ans User Interface: The user interface of the Android operating system is straight forward, and (1 M for
these features make it very user friendly. each
feature, 4
Multiple Language Support: Android supports multiple languages in its operating system and features
one can change the language very easily based on one’s requirement, the International expected)
languages supported are English, Germany, Chinese, Dutch, French, German, Japanese,
Korean, Russian, and many more also some native language of India is also Supported Like
Hindi, Marathi, Gujarati, Punjabi and many more.
Multi-tasking: Android provides support to run apps and services in the background with ease
which allows the users to use multiple apps at the same time.
Connectivity: Android has extensive support to the connectivity and it supports connectivity
such as WiFi, Bluetooth, Hotspot, CDMA, GSM, NFC, VOLTE, UBB, VPN, 3G network
band, and 4G Network Band.
Extensive Application Support: Android have Play store which is used as the major tool to
download and update applications on the operating system, however, one can download the
installer(often called as APK file) and install it manually, but it is not much recommended as
third party applications could be prone to some security breach in the smartphones.

b) Explain features of Android SDK. 4M

Ans Android SDK is a collection of libraries and Software Development tools that are essential for (1 M for
Developing Android Applications. Whenever Google releases a new version or update of each

Page No: 3 | 41
www.diplomachakhazana.in
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Android Software, a corresponding SDK also releases with it. In the updated or new version of feature, any
SDK, some more features are included which are not present in the previous version. Android 4 features
SDK consists of some tools which are very essential for the development of Android expected)
Application. These tools provide a smooth flow of the development process from developing
and debugging. Android SDK is compatible with all operating systems such as Windows,
Linux, macOS, etc.
1. Android Tool: This tool helps in managing the Android Virtual Device projects as well as
the installed components of the software development kit.
2. Emulator Tool: It helps us in testing the applications without the need of using the
application on an actual device.
3. Dalvik Debug Monitor Server(DDMS): DDMS is very useful for debugging the Android
Application.
4. Android Debug Bridge (ADB): It is a very versatile command-line tool and is helpful for
the communication between the developer and the Emulator or the Android device that is
connected.

c) Explain the Android security model. 4M

Ans The Android security model is primarily based on a sandbox and permission mechanism. Each 2 M for
application is running in a specific Dalvik virtual machine with a unique user ID assigned to it, explanation
which means the application code runs in isolation from the code of all other applications. , 2 M for
Therefore, one application has not granted access to other applications’ files. explaining
permissions
Android application has been signed with a certificate with a private key Know the owner of , any 2
the application is unique. This allows the author of the application will be identified if needed. permissions
When an application is installed in the phone is assigned a user ID, thus avoiding it from expected)
affecting it other applications by creating a sandbox for it. This user ID is permanent on which
devices and applications with the same user ID are allowed to run in a single process. This is a
way to ensure that a malicious application has Cannot access / compromise the data of the
genuine application. It is mandatory for an application to list all the resources it will Access
during installation. Terms are required of an application, in the installation process should be
user-based or interactive Check with the signature of the application.
Declaring and Using Permissions
The purpose of a permission is to protect the privacy of an Android user. Android apps must
request permission to access sensitive user data (such as contacts and SMS), as well as certain
system features (such as camera and internet). Depending on the feature, the system might grant
the permission automatically or might prompt the user to approve the request.
Permissions are divided into several protection levels. The protection level affects whether
runtime permission requests are required. There are three protection levels that affect third-
party apps: normal, signature, and dangerous permissions.
Normal permissions: Normal permissions cover areas where your app needs to access data or
resources outside the app’s sandbox, but where there’s very little risk to the user’s privacy or

Page No: 4 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
the operation of other apps. For example, permission to set the time zone is a normal
permission. If an app declares in its manifest that it needs a normal permission, the system
automatically grants the app that permission at install time. The system doesn’t prompt the user
to grant normal permissions, and users cannot revoke these permissions.
Signature permissions: The system grants these app permissions at install time, but only when
the app that attempts to use permission is signed by the same certificate as the app that defines
the permission.
Dangerous permissions: Dangerous permissions cover areas where the app wants data or
resources that involve the user’s private information, or could potentially affect the user’s
stored data or the operation of other apps. For example, the ability to read the user’s contacts is
a dangerous permission. If an app declares that it needs a dangerous permission, the user must
explicitly grant the permission to the app. Until the user approves the permission, your app
cannot provide functionality that depends on that permission. To use a dangerous permission,
your app must prompt the user to grant permission at runtime. For more details about how the
user is prompted, see Request prompt for dangerous permission.
d) Elaborate the need of permissions in Android. Explain the permissions to set 4M
system functionalitics like SEND-SMS, bluetooth.

Ans The purpose of a permission is to protect the privacy of an Android user. Android apps must(2 M for
request permission to access sensitive user data (such as contacts and SMS), as well as certain
explanation
system features (such as camera and internet). Depending on the feature, the system might grant
of need, 1
the permission automatically or might prompt the user to approve the request. M each for
explaining
 android. permission. SEND_SMS permissions
Allows the app to send SMS messages. This may result in unexpected charges. of Sms and
Malicious apps may cost you money by sending messages without your confirmation. bluetooth)

Following is the code snippet to set SEND_SMS permissions in manifest file.


<uses-permission android: name="android.permission.SEND_SMS"/>

 android. permission. BLUETOOTH


You need to provide following permissions in AndroidManifest.xml file.
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

3. Attempt any THREE of the following: 12 M

a) Explain data and time picker with its method. 4M

Ans Date Picker: Date picker


In Android, DatePicker is a widget used to select a date. It allows to select date by day, month (any two
and year in our custom UI (user interface). If we need to show this view as a dialog then we methods) 2
have to use a DatePickerDialog class. M and time
Methods of DatePicker:
picker (any
Page No: 5 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
1. setSpinnersShown(boolean shown): This method is used to set whether the spinner of the two
date picker in shown or not. In this method you have to set a Boolean value either true or false. methods) 2
True indicates spinner is shown, false value indicates spinner is not shown. Default value for M
this function is true.
Syntax:
DatePicker simpleDatePicker = (DatePicker)findViewById(R.id.simpleDatePicker);
simpleDatePicker.setSpinnersShown(false);
2. getDayOfMonth(): This method is used to get the selected day of the month from a date
picker.
This method returns an integer value.
DatePicker simpleDatePicker = (DatePicker) findViewById(R.id.simpleDatePicker);
int day = simpleDatePicker.getDayOfMonth();
3. getMonth(): This method is used to get the selected month from a date picker. This method
returns an integer value.
DatePicker simpleDatePicker = (DatePicker)findViewById(R.id.simpleDatePicker);
int month = simpleDatePicker.getMonth();
4. getYear(): This method is used to get the selected year from a date picker. This method
returns an integer value.
DatePicker simpleDatePicker = (DatePicker)findViewById(R.id.simpleDatePicker);
int year = simpleDatePicker.getYear();
5. getFirstDayOfWeek(): This method is used to get the first day of the week. This method
returns an integer value.
DatePicker simpleDatePicker = (DatePicker)findViewById(R.id.simpleDatePicker);
int firstDay=simpleDatePicker.getFirstDayOfWeek();
TimePicker:
In Android, TimePicker is a widget used for selecting the time of the day in either AM/PM
mode or 24 hours mode. The displayed time consist of hours, minutes and clock format. If we
need to show this view as a Dialog then we have to use a TimePickerDialog class.
Methods of TimePicker:
1. setCurrentHour(Integer currentHour): This method is used to set the current hours in a
time picker.
setHour(Integer hour): setCurrentHour() method was deprecated in API level 23. From api
level 23 we have to use setHour(Integer hour). In this method there is only one parameter of
integer type which is used to set the value for hours.
TimePicker simpleTimePicker=(TimePicker)findViewById(R.id.simpleTimePicker);
simpleTimePicker.setCurrentHour(5);
simpleTimePicker.setHour(5);
2. setCurrentMinute(Integer currentMinute): This method is used to set the current minutes
in a time picker. setMinute(Integer minute): setCurrentMinute() method was deprecated in API
level 23. From api level 23 we have to use setMinute(Integer minute). In this method there is
only one parameter of integer type which set the value for minutes.
TimePicker simpleTimePicker=(TimePicker)findViewById(R.id.simpleTimePicker);
simpleTimePicker.setCurrentMinute(35);
simpleTimePicker.setMinute(35);
4. getCurrentMinute(): This method is used to get the current minutes from a time picker.

www.diplomachakhazana.in Page No: 6 | 41


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
getMinute(): getCurrentMinute() method was deprecated in API level 23. From api level 23
we have to use getMinute(). This method returns an integer value.
TimePicker simpleTimePicker = (TimePicker)findViewById(R.id.simpleTimePicker);
int minutes = simpleTimePicker.getCurrentMinute();
int minutes = simpleTimePicker.getMinute();
5. setIs24HourView(Boolean is24HourView): This method is used to set the mode of the
Time picker either 24 hour mode or AM/PM mode. In this method we set a Boolean value
either true or false. True value indicate 24 hour mode and false value indicate AM/PM mode.
TimePicker simpleTimePicker = (TimePicker)findViewById(R.id.simpleTimePicker);
simpleTimePicker.setIs24HourView(true);
6. is24HourView(): This method is used to check the current mode of the time picker. This
method returns true if its 24 hour mode or false if AM/PM mode is set.
TimePicker simpleTimePicker = (TimePicker)findViewById(R.id.simpleTimePicker);
Boolean mode=simpleTimePicker.is24HourView();
7.setOnTimeChangedListener(TimePicker.OnTimeChangedListener
onTimeChanged(): This method is used to set the callback that indicates the time has been
adjusted by the user.
onTimeChanged(TimePicker view, int hourOfDay, int minute) is an override function of this
listener in which we have three parameters first is for TimePicker, second for getting hour of
the day and last is for getting the minutes after changing the time of the time picker.
TimePicker simpleTimePicker = (TimePicker)findViewById(R.id.simpleTimePicker);
simpleTimePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
}
});
b) Explain the steps to install and configure Android studio and SDK. 4M

Ans  Download the latest version of Android Studio from above URL and launch Android 4 M for
Studio.exe file by double clicking on it. steps
 The initial android studio setup screen will open in that click Next to continue for further
steps of environment setup
 Now we need to select a required components to setup an android environment. Here
we selected all three components (Android Studio, Android SDK and Android Virtual
Device) and click Next.
 Now we need to agree the License agreements to proceed further, click on I Agree
button
 Now we need to specify the local machine drive location to install Android Studio and
Android SDK.
 After selecting the location path to install required components, click Next.
 Now select the start menu folder to create a shortcut for android studio and click Install
 Once we click Install button the installation process will start and click Next after
completion of Installation.
 After that it will show installation completion wizard in that click Finish to launch
android studio While launching Android Studio it will give you an option to import

Page No: 7 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
settings from previous version of studio. In case if you don’t have any previous version,
select second option and click OK
 Now android studio will open a welcome wizard window in that click Next to validate
our current Android SDK and development environment setup
 Now select a Standard installation type and click Next to install a common settings and
options
 Now verify settings and click Finish to complete android studio setup process
 After completion of required components installation click on Finish
 After completion of all required components installation, we will be able to see Android
Studio welcome window
c) Explain the activity life cycle. 4M

Ans Diagram 2
M
explanation
2M

Activities have a predefined life-cycle methods as follows:

Page No: 8 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
onCreate (): Called then the activity is created. Used to initialize the activity, for
example create the user interface.

onStart ():called when activity is becoming visible to the user.

onResume (): Called if the activity get visible again and the user starts interacting
with the activity again. Used to initialize fields, register listeners, bind
to services, etc.

onPause (): Called once another activity gets into the foreground. Always called
before the activity is not visible anymore. Used to release resources or
save application data. For example you unregister listeners, intent
receivers, unbind from services or remove system service listeners.

onStop (): Called once the activity is no longer visible. Time or CPU intensive shutdown
operations, such as writing information to a database should be down in the onStop() method.
This method is guaranteed to be called as
of API 11.

onDestroy (): called before the activity is destroyed.

d) Explain the steps to deploy app on Google Play Store. 4M

Ans Step 1: Create a Developer Account 4 M for all


Before you can publish any app on Google Play, you need to create a Developer Account. You steps
can easily sign up for one using your existing Google Account. You’ll need to pay a one-time
registration fee of $25 using your international credit or debit card. It can take up to 48 hours
for your registration to be fully processed.

Step 2: Plan to Sell? Link Your Merchant Account


If you want to publish a paid app or plan to sell in-app purchases, you need to create a payments
center profile, i.e. a merchant account. A merchant account will let you manage your app sales
and monthly payouts, as well as analyze your sales reports right in your Play Console.

Step 3: Create an App


After creating application by clicking on ‘Create Application'. Here you have to select your
app’s default language from the drop-down menu and then type in a title for your app. The title
of your app will show on Google Play after you’ve published.

Step 4: Prepare Store Listing


Before you can publish your app, you need to prepare its store listing. These are all the details
that will show up to customers on your app’s listing on Google Play. You not necessarily
complete it at once, you can always save a draft and revisit it later when you’re ready to publish.
The information required for your store listing is divided into several categories such as
Product Details containing title, short and full description of the app, your app’s title and
description should be written with a great user experience in mind. Use the right keywords, but
don’t overdo it. Make sure your app doesn’t come across as spam-y or promotional, or it will
risk getting suspended on the Play Store.
Page No: 9 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Graphic Assets where you can add screenshots, images, videos, promotional graphics, and
icons that showcase your app’s features and functionality.
Languages & Translations, Categorization where in category can be selected to which your
app belong to. Contact Details, Privacy Policy for apps that request access to sensitive user
data or permissions, you need to enter a comprehensive privacy policy that effectively discloses
how your app collects, uses, and shares that data.

Step 5: Upload APK to an App Release


Finally upload your app, by uploading APK file. Before you upload APK, you need to create
an app release. You need to select the type of release you want to upload your first app version
to. You can choose between an internal test, a closed test, an open test, and a production release.
The first three releases allow you to test out your app among a select group of users before you
make it go live for everyone to access.
This is a safer option because you can analyze the test results and optimize or fix your app
accordingly if you need to before rolling it out to all users.
Once you create a production release, your uploaded app version will become accessible to
everyone in the countries you choose to distribute it in and click on ‘Create release.’

Step 6: Provide an Appropriate Content Rating


If you don’t assign a rating to your app, it will be listed as ‘Unrated’. Apps that are ‘Unrated’
may get removed from Google Play.
To rate your app, you need to fill out a content rating questionnaire An appropriate content
rating will also help you get to the right audience, which will eventually improve your
engagement rates.

Step 7: Set Up Pricing & Distribution


Before you can fill out the details required in this step, you need to determine your app’s
monetization strategy. Once you know how your app is going to make money, you can go ahead
and set up your app as free or paid.
You can always change your app from paid to free later, but you cannot change a free app to
paid. For that, you’ll need to create a new app and set its price.

Step 8: Rollout Release to Publish Your App


The final step involves reviewing and rolling out your release after making sure you’ve taken
care of everything else.
Before you review and rollout your release, make sure the store listing, content rating, and
pricing and distribution sections of your app each have a green check mark next to them.
Once you’re sure about the correctness of the details, select your app and navigate to ‘Release
management’ – ‘App releases.’ You can always opt for reviews by clicking on ‘Review’ to be
taken to the ‘Review and rollout release’ screen. Here, you can see if there are any issues or
warnings you might have missed out on.
Finally, select ‘Confirm rollout.’ This will also publish your app to all users in your target
countries on Google Play.

Page No: 10 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

4. Attempt any THREE of the following: 12 M

a) Explain the fundamentals of Ul design in detail. 4M

Ans 1. Views: 1 M for


• The basic building block for user interface in Android is a View, which is created from the each
View class and occupies a rectangular area on the screen and is responsible for drawing and
event handling.
• Views are the base class for all visual interface elements (commonly known as controls or
widgets). All user interface UI controls, including the layout classes, are derived from View.
• A View is an object/widget that draws something on the sreen by the help of user interact.
• Examples of widgets are buttons, text boxes, labels etc.
2. View Groups:
• The ViewGroup is a subclass of View and provides invisible container that hold other Views
or other ViewGroups and define their layout properties.
• View groups are extensions of the View class that can contain multiple child Views. In order
to Extend the ViewGroup class to create compound controls made up of interconnected child
views.
• A ViewGroup provides the layout in which we can order the appearance and sequence of
views.
Examples of ViewGroup are FrmaeLayout, LineourLayout etc.
3. Fragments:
• Fragments represents a portion of user interface in an Activity. Fragments, introduced in
Android 3.0 which uses API level 11, are used to encapsulate portions of your UI. This
encapsulation makes fragments particularly useful when optimizing our UI layouts for different
screen sizes and creating reusable user interface (UI) elements.
• Each Fragment includes its own user interface (UI) layout and receives the related input events
but is tightly bound to the activity into which each must be embedded. Fragments are similar
to UI view controller in iPhone development.
4. Activities:
• Activities dictate the UI and handle the user interaction to the smart phone screen. Activities
represent a single screen that user interact.
• Activities are the Android equivalent of Forms in traditional windows desktop development.
To display a UI we assign a View (Usually a layout or Fragment) to an Activity
b) Write a program to display a rectangular progress bar. 4M

Ans Xml File: xml file


<?xml version="1.0" encoding="utf-8"?> 2M,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" java file 2
android:layout_width="match_parent" M
android:layout_height="match_parent"
tools:context=".MainActivity">
Page No: 11 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

<ProgressBar
android:id="@+id/progressBar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:indeterminate="false"
android:max="100"
android:minHeight="50dp"
android:minWidth="200dp"
android:progress="1" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/progressBar"
android:layout_below="@+id/progressBar"/>
</RelativeLayout>
Java file:
package in.edu.vpt.progressbar;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.widget.ProgressBar;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private ProgressBar progressBar;
private int progressStatus = 0;
private TextView textView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
textView = (TextView) findViewById(R.id.textView);
// Start long running operation in a background thread
new Thread(new Runnable() {
public void run() {

Page No: 12 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
while (progressStatus < 100) {
progressStatus += 1;
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
progressBar.setProgress(progressStatus);
textView.setText(progressStatus+"/"+progressBar.getMax());
}
});
try {
// Sleep for 200 milliseconds.
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
}
}
c) Explain Android system architecture in detail. 4M

Ans Diagram

2 M,

Explanation
2M

1. Applications:
• The top layer of android architecture is Applications. The native and third party applications
like Contacts, Email, Music, Gallery, Clock, Games, etc. whatever we will build those will be
installed on this layer only.
Page No: 13 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• The application layer runs within the Android run time using the classes and services made
available from the application framework.
2. Application Framework:
• The Application Framework provides the classes used to create an Android application. It also
provides a generic abstraction for hardware access and manages the user interface and
application resources.
• It basically provides the services through which we can create the particular class and make
that class helpful for the Applications creation.
• The application framework includes services like telephony service, location services,
notification manager, NFC service, view system, etc. which we can use for application
development as per our requirements.
3. Android Runtime:
• Android Runtime environment is an important part of Android rather than an internal part and
it contains a components like core libraries and the Dalvik virtual machine.
• The Android run time is the engine that powers our applications along with the libraries and
it forms the basis for the application framework.
(i) Dalvik Virtual Machine (DVM) is a register-based virtual machine like Java Virtual
Machine (JVM).
It is specially designed and optimized for android to ensure that a device can run multiple
instances efficiently. It relies on the Linux kernel for threading and low-level memory
management.
(ii) The core libraries in android runtime will enable us to implement an android applications
using standard JAVA programming language.
4. Platform Libraries:
• The Platform Libraries includes various C/C++ core libraries and Java based libraries such as
SSL, libc, Graphics, SQLite, Webkit, Media, Surface Manger, OpenGL etc. to provide a
support for android development.
5. Linux Kernel:
• Linux Kernel is a bottom layer and heart of the android architecture. It is heart of Android
architecture that exists at the root of android architecture and contains all the low-level device
drivers for the various hardware components of an Android device.
• Linux Kernel is responsible for device drivers, power management, memory management,
device management and resource access. It manage all the drivers such as display drivers,
camera drivers, Bluetooth drivers, audio drivers, memory drivers, etc. which are mainly
required for the android device during the runtime.
• The Linux Kernel will provide an abstraction layer between the device hardware and the
remainder of the stack. It is responsible for memory management, power management, device
management, resource access, etc.
d) Explain the procedure of Geo-coding and reverse Geo-coding. 4M

Ans Geo-Coding: geocoding 2


• If we know the latitude and longitude of a location, we can find out its address using a process M
known as Geocoding. Google Maps in Android supports this via the Geocoder class.

Page No: 14 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• The following code shows how we can find out the address of a location we have just touched and
using the getFromLocation() method: reverse
classMapOverlay extends com.google.android.maps.Overlay geocoding 2
M
{
@Override
publicboolean draw(Canvas canvas, MapViewmapView,
boolean shadow, long when)
{
//...
}
@Override
publicbooleanonTouchEvent(MotionEvent event, MapViewmapView)
{
//---when user lifts his finger---
if (event.getAction() == 1) {
GeoPoint p = mapView.getProjection().fromPixels(
(int) event.getX(),
(int) event.getY());
Geocoder geoCoder = new Geocoder(
getBaseContext(), Locale.getDefault());
try {
List<Address> addresses = geoCoder.getFromLocation(
p.getLatitudeE6() / 1E6,
p.getLongitudeE6() / 1E6, 1);
String add = "";
if (addresses.size() > 0)
{
for (inti=0; i<addresses.get(0).getMaxAddressLineIndex();
i++)
add += addresses.get(0).getAddressLine(i) + "n";
}
Toast.makeText(getBaseContext(), add, Toast.LENGTH_SHORT).show();
}
catch (IOException e) {
e.printStackTrace();
}
return true;
}
else
return false;
}
}

Page No: 15 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Reverse-geocoding:
If we know the address of a location but want to know its latitude and longitude, we can do so
via reverse-Geocoding. Again, we can use the Geocoder class for this purpose.
• The following code shows how we can find the exact location of the Empire State Building
by using the getFromLocationName() method:
Geocoder geoCoder = new Geocoder(this, Locale.getDefault());
try {
List<Address> addresses = geoCoder.getFromLocationName(
"empire state building", 5);
String add = "";
if (addresses.size() > 0) {
p = new GeoPoint(
(int) (addresses.get(0).getLatitude() * 1E6),
(int) (addresses.get(0).getLongitude() * 1E6));
mc.animateTo(p);
mapView.invalidate();
}
} catch (IOException e) {
e.printStackTrace();
}
Once. the location is found, the above code navigates the map to the location.
e) Develop an application to send and receive SMS (Write only Java and 4M
permission tag in manifest file).
Ans Permissions and <receiver> tag required in AndroidManifest.xml Manifest
<uses-permission android:name="android.permission.RECEIVE_SMS" /> File:1M
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/> Java Code:
<uses-permission android:name="android.permission.WRITE_SMS"/> 3M

<receiver
android:name=".SmsReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>

MainActivity.java
(Cosidering appropriate layout file with 2 edit text boxes namely for phone number,
message and a button for sending sms)

package com.example.testreceivesms;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;

Page No: 16 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


SmsReceiver sms= new SmsReceiver();
EditText et1,et2;
Button b1;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1=findViewById(R.id.etPhno);
et2=findViewById(R.id.etmsg);
b1=findViewById(R.id.btnSms);
if(ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.SEND_S
MS)!=
PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(MainActivity.this,new
String[]{Manifest.permission.SEND_SMS},100);
}
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
String phno= et1.getText().toString();
String msg=et2.getText().toString();
SmsManager smsManager= SmsManager.getDefault();
smsManager.sendTextMessage(phno,null,msg,null,null);
Toast.makeText(MainActivity.this,"Sms sent successfully",
Toast.LENGTH_LONG).show();
}
catch(Exception e)
{
Toast.makeText(MainActivity.this,"Sms failed to send... try again",
Toast.LENGTH_LONG).show();
}
}
});
}
@Override
Page No: 17 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
protected void onStart() {
super.onStart();
IntentFilter filter=new IntentFilter("android.provider.Telephony.SMS_RECEIVED");
registerReceiver(sms,filter);
}

@Override
protected void onStop() {
super.onStop();
unregisterReceiver(sms);
}
}

SmsReceiver.java
package com.example.testreceivesms;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.widget.Toast;

public class SmsReceiver extends BroadcastReceiver {


SmsReceiver(){}
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();

if (bundle != null) {
// Retrieve the SMS Messages received
Object[] sms = (Object[]) bundle.get("pdus");

// For every SMS message received


for (int i=0; i < sms.length; i++) {
// Convert Object array
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i]);

String phone = smsMessage.getOriginatingAddress();


String message = smsMessage.getMessageBody().toString();

Toast.makeText(context, “Received from “+ phone + ": " + message,


Toast.LENGTH_SHORT).show();
}
}
}
}

5. Attempt any TWO of the following: 12 M

Page No: 18 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
a) Develop a program to send and receive an Email. 6M

Ans Program to send Email Any correct


activity_main.xml logic
<?xml version="1.0" encoding="utf-8"?> program
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" should be
xmlns:tools="http://schemas.android.com/tools" considered,
android:layout_width="match_parent" 3M for
android:layout_height="match_parent" send logic,
tools:context=".MainActivity"> 3M for
receive
<EditText logic
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginTop="18dp"
android:layout_marginRight="22dp" />

<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText1"
android:layout_alignLeft="@+id/editText1"
android:layout_marginTop="20dp" />

<EditText
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText2"
android:layout_alignLeft="@+id/editText2"
android:layout_marginTop="30dp" />

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText1"
android:layout_alignBottom="@+id/editText1"
android:layout_alignParentLeft="true"
android:text="Send To:"
android:textColor="#0F9D58" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
Page No: 19 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText2"
android:layout_alignBottom="@+id/editText2"
android:layout_alignParentLeft="true"
android:text="Email Subject:"
android:textColor="#0F9D58" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText3"
android:layout_alignBottom="@+id/editText3"
android:text="Email Body:"
android:textColor="#0F9D58" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText3"
android:layout_alignLeft="@+id/editText3"
android:layout_marginLeft="76dp"
android:layout_marginTop="20dp"
android:text="Send email!!" />
</RelativeLayout>

MainActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
// define objects for edit text and button
Button button;
EditText sendto, subject, body;

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

// Getting instance of edittext and button


sendto = findViewById(R.id.editText1);
subject = findViewById(R.id.editText2);
body = findViewById(R.id.editText3);
button = findViewById(R.id.button);

Page No: 20 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
// attach setOnClickListener to button with Intent object define in it
button.setOnClickListener(view -> {
String emailsend = sendto.getText().toString();
String emailsubject = subject.getText().toString();
String emailbody = body.getText().toString();

// define Intent object with action attribute as ACTION_SEND


Intent intent = new Intent(Intent.ACTION_SEND);

// add three fields to intent using putExtra function


intent.putExtra(Intent.EXTRA_EMAIL, new String[]{emailsend});
intent.putExtra(Intent.EXTRA_SUBJECT, emailsubject);
intent.putExtra(Intent.EXTRA_TEXT, emailbody);

// set type of intent


intent.setType("message/rfc822");

// startActivity with intent with chooser as Email client using


createChooser function
startActivity(Intent.createChooser(intent, "Choose an Email client :"));
});
}
}

Program to receive Email


(Note: Receiving email is not the service of Android OS, instead it uses some third party
applicaton like Gmail, so instead of receiving email in android app, a code which broadcasts
message if email comes using broadcast receiver or any relevant logic can be considered.)
MainActivity.java
package com.example.myemailprog;
import androidx.appcompat.app.AppCompatActivity;
import android.content.IntentFilter;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {


GmailReceiver gml;
IntentFilter intf;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gml = new GmailReceiver();
intf = new IntentFilter("android.intent.action.VIEW");
}

@Override
protected void onResume() {
super.onResume();

Page No: 21 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
registerReceiver(gml, intf);
}

@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(gml);
}
}
Gmailrerciever..java
package com.example.myemailprog;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.BitmapFactory;
import android.widget.Toast;

public class GmailReceiver extends BroadcastReceiver


{
@Override
public void onReceive(Context context, Intent intent)
{
Toast.makeText(context, "Email Received", Toast.LENGTH_LONG).show();

}
}

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myemailprog">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyEmailProg">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Page No: 22 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
</intent-filter>
</activity>
<receiver android:name="GmailReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.PROVIDER_CHANGED"
android:priority="-10">
</action>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="content" android:host="gmail-ls"
android:pathPattern="/unread/.*">
</data>
</intent-filter>
</receiver>
</application>
</manifest>
b) Develop a program for providing bluetooth connectivity. 6M

Ans activity_main.xml Layout file


<RelativeLayout xmlns:androclass="http://schemas.android.com/apk/res/android" : 2M
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" Java File :
android:layout_height="match_parent" 3M
tools:context=".MainActivity" >
Manifest
file : 1M
<TextView android:text=""
android:id="@+id/out"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
<Button

android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="49dp"
android:text="TURN_ON" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:layout_marginTop="27dp"
android:text="DISCOVERABLE" />

Page No: 23 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button2"
android:layout_below="@+id/button2"
android:layout_marginTop="28dp"
android:text="TURN_OFF" />

</RelativeLayout>

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:androclass="http://schemas.android.com/apk/res/android"
package="com.example.bluetooth"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.bluetooth.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

MainActivity.java
package com.example.bluetooth;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
Page No: 24 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends Activity {


private static final int REQUEST_ENABLE_BT = 0;
private static final int REQUEST_DISCOVERABLE_BT = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView out=(TextView)findViewById(R.id.out);
final Button button1 = (Button) findViewById(R.id.button1);
final Button button2 = (Button) findViewById(R.id.button2);
final Button button3 = (Button) findViewById(R.id.button3);
final BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {
out.append("device not supported");
}
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
if (!mBluetoothAdapter.isDiscovering()) {
//out.append("MAKING YOUR DEVICE DISCOVERABLE");
Toast.makeText(getApplicationContext(), "MAKING YOUR DEVICE DISCOVERA
BLE",
Toast.LENGTH_LONG);

Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVER


ABLE);
startActivityForResult(enableBtIntent, REQUEST_DISCOVERABLE_BT);

}
}
});
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Page No: 25 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
mBluetoothAdapter.disable();
//out.append("TURN_OFF BLUETOOTH");
Toast.makeText(getApplicationContext(), "TURNING_OFF BLUETOOTH", Toast.LENGT
H_LONG);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}

}
c) Develop a program to implement 6M

i) List view of 5 items


ii) Grid view of 4 x 4 items
iii) Image view.

Ans <?xml version="1.0" encoding="utf-8"?> Correct


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" Logics for
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto" ListView :
android:layout_width="match_parent" 2M
android:layout_height="match_parent"
GridView :
android:orientation="vertical"
2M
tools:context=".MainActivity">
ImageView
<ListView : 2M
android:id="@+id/sample_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>

<GridView
android:id="@+id/gridview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:columnWidth="50dp"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>

<ImageView
android:id="@+id/full_logo"
android:layout_width="match_parent"

Page No: 26 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"
app:srcCompat="@drawable/android_logo" />

</LinearLayout>
Placed image that has to be displayed in drawable folder

package in.msbte.controls_exam_ques;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ListView;

public class MainActivity extends AppCompatActivity {


String[] sampleArray = {"Item 1","Item 2","Item 3","Item 4", "Item 5"};
GridView gridView;
static final String[] alphabets = new String[]{
"A", "B", "C", "D", "E",
"F", "G", "H", "I", "J",
"K", "L", "M", "N", "O",
"P", "Q", "R", "S", "T",
"U", "V", "W", "X", "Y", "Z"
};
ArrayAdapter adapter, adapter1;

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

//List View
adapter = new ArrayAdapter<String>(this, R.layout.simple_item, sampleArray);
ListView listView = (ListView) findViewById(R.id.sample_list);
listView.setAdapter(adapter);

//Grid View
gridView = (GridView) findViewById(R.id.gridview1);
adapter1 = new ArrayAdapter<String>(this, R.layout.simple_item, alphabets);
gridView.setAdapter(adapter1);

}
}
6. Attempt any TWO of the following: 12 M

Page No: 27 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
a) Develop an application to store customer's details like, customer-id, customer-name, 6M
mobile number, address, pin-code and retrieve customer information using customer-id
in SQLite databases.
(Any other relevant logic can be considered)
Ans activity_main.xml Layout File
<?xml version="1.0" encoding="utf-8"?> : 1M
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" Java File :
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" Correct
android:layout_height="match_parent" Logics for
tools:context=".MainActivity">
Create
table : 1M
<TextView Insertion of
android:text="Insert Customer Details" record : 2M
android:layout_width="wrap_content" Retrival of
android:layout_height="wrap_content" data : 2M
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:id="@+id/textView"
android:gravity="center"
android:textSize="20dp"
android:textColor="#000000"/>

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="ID"
android:id="@+id/editid"
android:layout_below="@+id/textView"/>

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Name"
android:id="@+id/editname"
android:layout_below="@+id/editid"/>

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Mobile No."
android:id="@+id/editmobile"
android:layout_below="@+id/editname"/>
Page No: 28 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Address"
android:lines="3"
android:id="@+id/editaddress"
android:layout_below="@+id/editmobile"/>

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Pin Code"
android:id="@+id/editpincode"
android:layout_below="@+id/editaddress"/>

<Button
android:text="Insert Data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/editpincode"
android:layout_centerHorizontal="true"
android:id="@+id/button" />

<TextView
android:text="Search Customer Details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_centerHorizontal="true"
android:id="@+id/textView1"
android:gravity="center"
android:textSize="20dp"
android:layout_below="@+id/button"
android:textColor="#000000"/>

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Enter ID"
android:id="@+id/editsearchid"
android:layout_below="@+id/textView1"/>

Page No: 29 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<Button
android:text="Search Data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/editsearchid"
android:layout_centerHorizontal="true"
android:id="@+id/button1" />
</RelativeLayout>

MainActivity.java
package in.msbte.database;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


SQLiteDatabase sqLiteDatabaseObj;
EditText editTextID, editTextName, editMobileNo, editAddress, editPincode,
editSearchid;
String cid, cname, cmobile, caddress, cpincode, sql_query, sid;
Button EnterData, SearchData;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EnterData = (Button)findViewById(R.id.button);
SearchData = (Button)findViewById(R.id.button1);
editTextID = (EditText)findViewById(R.id.editid);
editTextName = (EditText)findViewById(R.id.editname);
editMobileNo = (EditText)findViewById(R.id.editmobile);
editAddress = (EditText)findViewById(R.id.editaddress);
editPincode = (EditText)findViewById(R.id.editpincode);
editSearchid = (EditText)findViewById(R.id.editsearchid);

EnterData.setOnClickListener(new View.OnClickListener() {
@Override
Page No: 30 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
public void onClick(View view) {
sqLiteDatabaseObj = openOrCreateDatabase("AndroidJSonDataBase",
Context.MODE_PRIVATE, null);
sqLiteDatabaseObj.execSQL("CREATE TABLE IF NOT EXISTS
AndroidJSonTable(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, cid
VARCHAR, name VARCHAR, mobile VARCHAR, address VARCHAR, pincode
VARCHAR);");
cid = editTextID.getText().toString();
cname = editTextName.getText().toString() ;
cmobile = editMobileNo.getText().toString();
caddress = editAddress.getText().toString();
cpincode = editPincode.getText().toString();
sql_query = "INSERT INTO AndroidJSonTable (cid, name, mobile, address,
pincode) VALUES('"+cid+"', '"+cname+"', '"+cmobile+"', '"+caddress+"', '"+cpincode+"');";
sqLiteDatabaseObj.execSQL(sql_query);
Toast.makeText(getApplicationContext(), "Data Inserted Successfully",
Toast.LENGTH_LONG).show();
}
});

SearchData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sid = editSearchid.getText().toString();
Cursor cursor = sqLiteDatabaseObj.rawQuery( "select * from AndroidJSonTable
where cid="+sid+"", null );
StringBuffer buffer= new StringBuffer();
while (cursor.moveToNext())
{
String cid =cursor.getString(1);
String name =cursor.getString(2);
String mob =cursor.getString(3);
String addr =cursor.getString(4);
String pcode =cursor.getString(5);
buffer.append(cid+ " " + name + " " + mob +" " + addr +" " + pcode +"
\n");
Toast.makeText(getApplicationContext(), buffer,
Toast.LENGTH_LONG).show();
} }); } }
b) Write a program to find the direction from user's current location to MSBTE, 6M
Bandra. (Write only Java and manitest file).
(Note : Any other relevant logic to get the required output can also be considered.)

Page No: 31 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans AndroidManifest.xml Manifest
file :2M
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" Java File :
package="com.example.msbte.google_map_currentlocationroute"> 4M

<uses-permission android:name="android.permission.INTERNET" />


<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"
/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
</application>
</manifest>

MainActivity.java

import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.net.Uri;
import android.provider.Settings;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

Page No: 32 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.karumi.dexter.Dexter;
import com.karumi.dexter.MultiplePermissionsReport;
import com.karumi.dexter.PermissionToken;
import com.karumi.dexter.listener.DexterError;
import com.karumi.dexter.listener.PermissionRequest;
import com.karumi.dexter.listener.PermissionRequestErrorListener;
import com.karumi.dexter.listener.multi.MultiplePermissionsListener;
import java.util.List;

public class MainActivity extends AppCompatActivity implements


GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener,
com.google.android.gms.location.LocationListener , OnMapReadyCallback,
TaskLoadedCallback{

//variables for map and route

private GoogleMap mMap;


private MarkerOptions place1, place2;
Button getDirection;
private Polyline currentPolyline;
private MapFragment mapFragment;
private boolean isFirstTime = true;

//variables for current location


private static final String TAG = "MainActivity";

private TextView tvLocation;


private GoogleApiClient mGoogleApiClient;
private Location mLocation;
private LocationRequest mLocationRequest;
private com.google.android.gms.location.LocationListener listener;
private long UPDATE_INTERVAL = 2 * 1000; /* 10 secs */
Page No: 33 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
private long FASTEST_INTERVAL = 2000; /* 2 sec */

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

//code for getting current location


requestMultiplePermissions();
tvLocation = (TextView) findViewById((R.id.tv));
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}

//code for drawing route

@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.clear();
Log.d("mylog", "Added Markers");
mMap.addMarker(place1);
mMap.addMarker(place2);

CameraPosition googlePlex = CameraPosition.builder()


.target(new LatLng(22.7739,71.6673))
.zoom(7)
.bearing(0)
.tilt(45)
.build();

mMap.animateCamera(CameraUpdateFactory.newCameraPosition(googlePlex), 5000,
null);
}

private String getUrl(LatLng origin, LatLng dest, String directionMode) {


// Origin of route
String str_origin = "origin=" + origin.latitude + "," + origin.longitude;
// Destination of route
String str_dest = "destination=" + dest.latitude + "," + dest.longitude;
// Mode
String mode = "mode=" + directionMode;
// Building the parameters to the web service
String parameters = str_origin + "&" + str_dest + "&" + mode;
// Output format
String output = "json";
Page No: 34 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
// Building the url to the web service
String url = "https://maps.googleapis.com/maps/api/directions/" + output + "?" +
parameters + "&key=" + getString(R.string.google_maps_key);
return url;
}

@Override
public void onTaskDone(Object... values) {
if (currentPolyline != null)
currentPolyline.remove();
currentPolyline = mMap.addPolyline((PolylineOptions) values[0]);
}

//runtime permission method

private void requestMultiplePermissions(){


Dexter.withActivity(this)
.withPermissions(
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION )
.withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
// check if all permissions are granted
if (report.areAllPermissionsGranted()) {
Toast.makeText(getApplicationContext(), "All permissions are granted by
user!", Toast.LENGTH_SHORT).show();
}

// check for permanent denial of any permission


if (report.isAnyPermissionPermanentlyDenied()) {
// show alert dialog navigating to Settings
openSettingsDialog();
}
}

@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest>
permissions, PermissionToken token) {
token.continuePermissionRequest();
}
}).
withErrorListener(new PermissionRequestErrorListener() {
@Override
public void onError(DexterError error) {
Toast.makeText(getApplicationContext(), "Some Error! ",
Toast.LENGTH_SHORT).show();
}
})
Page No: 35 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
.onSameThread()
.check();
}

private void openSettingsDialog() {


AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Required Permissions");
builder.setMessage("This app require permission to use awesome feature. Grant them in
app settings.");
builder.setPositiveButton("Take Me To SETTINGS", new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
Intent intent = new
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivityForResult(intent, 101);
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}

//methods for getting current location


@Override
public void onConnected(Bundle bundle) {
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
return;
}

startLocationUpdates();
mLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
if(mLocation == null){
startLocationUpdates();
}
if (mLocation != null) {
// mLatitudeTextView.setText(String.valueOf(mLocation.getLatitude()));
//mLongitudeTextView.setText(String.valueOf(mLocation.getLongitude()));
Page No: 36 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
} else {
Toast.makeText(this, "Location not Detected", Toast.LENGTH_SHORT).show();
} }

@Override
public void onConnectionSuspended(int i) {
Log.i(TAG, "Connection Suspended");
mGoogleApiClient.connect();
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.i(TAG, "Connection failed. Error: " + connectionResult.getErrorCode());
}
@Override
protected void onStart() {
super.onStart();
if (mGoogleApiClient != null) {
mGoogleApiClient.connect();
} }

@Override
protected void onStop() {
super.onStop();
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
} }

protected void startLocationUpdates() {


// Create the location request
mLocationRequest = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.setInterval(UPDATE_INTERVAL)
.setFastestInterval(FASTEST_INTERVAL);
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
return;
}
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,
mLocationRequest, this);
}

@Override
public void onLocationChanged(Location location) {

String msg = "Updated Location: " +


Double.toString(location.getLatitude()) + "," +
Page No: 37 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Double.toString(location.getLongitude());

tvLocation.setText(String.valueOf(location.getLatitude() +"
"+String.valueOf(location.getLongitude())));
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();

if(isFirstTime){
//code to draw path on map

getDirection = findViewById(R.id.btnGetDirection);
getDirection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new FetchURL(MainActivity.this).execute(getUrl(place1.getPosition(),
place2.getPosition(), "driving"), "driving");
}
});

place1 = new MarkerOptions().position(new LatLng(location.getLatitude(),


location.getLongitude())).title("Location 1");
place2 = new MarkerOptions().position(new
LatLng(19.021824,72.8662016)).title("MSBTE");
mapFragment = (MapFragment)
getFragmentManager().findFragmentById(R.id.mapNearBy);
mapFragment.getMapAsync(this);
isFirstTime = false;
} }}
c) Develop a simple calculator using relative layout. 6M

Ans activity_main.xml Use of


<?xml version="1.0" encoding="utf-8"?> Relative
<RelativeLayout Layout
xmlns:android="http://schemas.android.com/apk/res/android" with
appropriate
xmlns:app="http://schemas.android.com/apk/res-auto" attributes :
xmlns:tools="http://schemas.android.com/tools" 3M
android:layout_width="match_parent"
android:layout_height="match_parent" Logic for
simple
tools:context=".MainActivity">
calculator
with basic
<TextView arithmetic
android:id="@+id/heading" operations :
android:layout_width="wrap_content" 3M
android:layout_height="wrap_content"
android:text=" Calculator"
android:layout_centerHorizontal="true"
android:textSize="30dp" />

Page No: 38 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<EditText
android:id="@+id/num1"
android:layout_below="@+id/heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Number 1"
android:inputType="number" />

<EditText
android:id="@+id/num2"
android:layout_below="@+id/num1"
android:hint="Enter Number 2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />

<TextView
android:id="@+id/result"
android:layout_below="@+id/num2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:text="Result" />

<Button
android:id="@+id/sum"
android:layout_below="@id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="+" />

<Button
android:id="@+id/sub"
android:layout_below="@id/result"
android:layout_toRightOf="@id/sum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="-" />

<Button
Page No: 39 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:id="@+id/div"
android:layout_below="@id/result"
android:layout_toRightOf="@id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="/" />

<Button
android:id="@+id/mul"
android:layout_below="@id/result"
android:layout_toRightOf="@id/div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="x"/>
</RelativeLayout>

MainActivity.java
package in.msbte.calculator;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
public EditText e1, e2;
Button add, sub , mul, div;
TextView t1;
int num1, num2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e1 = (EditText) findViewById(R.id.num1);
e2 = (EditText) findViewById(R.id.num2);
t1 = (TextView) findViewById(R.id.result);
add = (Button) findViewById(R.id.sum);
mul = (Button) findViewById(R.id.mul);
div = (Button) findViewById(R.id.div);
sub = (Button) findViewById(R.id.sub);
add.setOnClickListener(new View.OnClickListener() {
Page No: 40 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
@Override
public void onClick(View view) {
num1 = Integer.parseInt(e1.getText().toString());
num2 = Integer.parseInt(e2.getText().toString());
int sum = num1 + num2;
t1.setText(Integer.toString(sum));
}
});
sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
num1 = Integer.parseInt(e1.getText().toString());
num2 = Integer.parseInt(e2.getText().toString());
int sum = num1 - num2;
t1.setText(Integer.toString(sum));
}
});
mul.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
num1 = Integer.parseInt(e1.getText().toString());
num2 = Integer.parseInt(e2.getText().toString());
int sum = num1 * num2;
t1.setText(Integer.toString(sum));
}
});
div.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
num1 = Integer.parseInt(e1.getText().toString());
num2 = Integer.parseInt(e2.getText().toString());
int sum = num1 / num2;
t1.setText(Integer.toString(sum));
}
});
}
}

Page No: 41 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
SUMMER – 2023 EXAMINATION
Model Answer – Only for the Use of RAC Assessors

te
Subject Name: Mobile Application Development Subject Code: 22617

al
Important Instructions to examiners: XXXXX

lc
1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the

le
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not applicable for

a
subject English and Communication Skills.

r.c
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The figures
drawn by candidate and model answer may vary. The examiner may give credit for any equivalent figure drawn.

om
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may vary and
there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based on
candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual (English +
Marathi) medium is introduced at first year of AICTE diploma Programme from academic year 2021-2022. Hence if
the students in first year (first and second semesters) write answers in Marathi or bilingual language (English
+Marathi), the Examiner shall consider the same and assess the answer based on matching of concepts with model
answer.

Q. Sub Answer Marking


No. Q. Scheme
N.

1 Attempt any FIVE of the following: 10 M

a) State Android ECO System. 2M

Ans Android Ecosystem Any 4


points
2M

• Ecosystem in Market terminology refers to the inter-dependence between demand


and supply.

Page No: 1 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
In the Android ecosystem this translates to inter-dependence between users,
developers, and equipment makers. One cannot exist without the other:

te
▪ Google develops android
▪ Users buy devices and applications

al
▪ Original Equipment makers sell devices, sometimes bundled with applications

lc
▪ Developers buy devices, then make and sell applications

le
▪ Freelance Android Developer developers have the skills to contribute to the
ecosystem for android development , they are who creates their own applications and

a
published them on googles play store.

r.c
om
b) List various tools for android application development 2M

Ans • Android Studio Any


• ADB (Android Debug Bridge)
4 tools
• AVD Manager
• Eclipse 2M
• Fabric
• FlowUp
• GameMaker: Studio
• Genymotion
• Gradle IntelliJ IDEA
c) List various layouts used in android UI design. 2M

Ans • Linear Layout Any


• Absolute Layout
4 layouts
• Frame Layout
• Table Layout 2M
• Relative Layout
d) Name any four attributes of Edit Text control. 2M

Ans android:id Any


android: gravity
android: text 4 attributes
android: hint
2M
android: textColor
android: textSize
android: textStyle
android: background

e) State the use of fragments in android App development. 2M

Ans Android Fragment is the part of activity, it is also known as sub-activity. There can be more Explanation
2M
than one fragment in an activity.

Fragments represent multiple screen inside one activity.

Page No: 2 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
We can create Fragments by extending Fragment class or by inserting a Fragment into our
Activity layout by declaring the Fragment in the activity’s layout file, as

te
a <fragment> element.

al
Fragments were added in Honeycomb version of Android i.e API version 11. We can add,

lc
replace or remove Fragment’s in an Activity while the activity is running.

le
Fragment can be used in multiple activities.

a
We can also combine multiple Fragments in a single activity to build a multi-plane UI.

r.c
We can only show a single Activity on the screen at one given point of time so we were not
able to divide the screen and control different parts separately. With the help of Fragment’s

om
we can divide the screens in different parts and controls different parts separately

f) Define SMS service in android application development. 2M

Ans SMS Any

• In Android, you can use SmsManager API or devices Built-in SMS application to 4 points
send SMS's
2M
• Android SMS is stored in PDU (protocol description unit) format
• SmsManager class takes care of sending the SMS message.
• We just need to get an instance of it and send the SMS message.
• We need to add permission to SEND_SMS in the Android manifest file.

SmsManager smsManager = SmsManager.getDefault();


smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);
g) List different types of sensors used in android. 2M

Ans The android platform supports three broad categories of sensors. 2 M for List

• Motion Sensors

These are used to measure acceleration forces and rotational forces along with three
axes.

• Environmental sensors

These are used to measure the environmental changes such as temperature, humidity etc.

• Position sensors

These are used to measure the physical position of device.

Page No: 3 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
2. Attempt any THREE of the following: 12 M

a) Describe android and importance of OHA. 4M

te
Ans Android Explain

al
android 2 M
Android is an open source and Linux-based Operating System .It is designed primarily for

lc
touch screens mobile devices such as smartphones and tablet computers. Android offers a Importance

le
unified approach to application development for mobile devices which means developers 2M
need only develop for Android, and their applications should be able to run on different

a
devices powered by Android.

r.c
Android was developed by the Open Handset Alliance, led by Google, and other companies.

om
OHA

• The Open Handset Alliance (OHA) is a business alliance that was created for the
purpose of developing open mobile device standards.
• The OHA has approximately 80 member companies, including HTC, Dell, Intel,
Motorola, Qualcomm and Google.
Importance of OHA

• Lower overall handset costs: Opens up resources, which facilitates the focus on
creating innovative applications, solutions and services.
• Developer-friendly environment: In the open-source community, developers share
notes to expedite application development.
• Post-development: Provides an ideal channel for application marketing and
distribution.

b) Explain Dalvik Virtual Machine and state its importance. 4M

Ans The Dalvik Virtual Machine (DVM) is an android virtual machine optimized for mobile Explain 2
devices. M

Dalvik VM is also a virtual machine that is highly optimized for mobile devices. Importance
2M
Thus, it provides all the three things, that are memory management, high performance as
well as battery life.

It is strictly developed for Android mobile phones.

Page No: 4 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
te
al
lc
le
a r.c
om
The Dex compiler converts the class files into the .dex file that run on the Dalvik VM.
Multiple class files are converted into one dex file.

The javac tool compiles the java source file into the class file.

The dx tool takes all the class files of your application and generates a single .dex file. It is a
platform-specific tool.

The Android Assets Packaging Tool (aapt) handles the packaging process.
c) Describe the process of getting the map API key. 4M

Ans Creating API keys Correct


Steps 4
The API key is a unique identifier that authenticates requests associated with your project marks
for usage and billing purposes. You must have at least one API key associated with your
project.

1. Browse the site on your browser. https://console. developers. google.com/project


2. Login with your google account.
3. Create a new project by clicking on Create Project option.
4. Add your project name and organization name in the fields present on the screen.
5. Now click on APIs and Services.
6. Enable APIs and services.
7. Select Google maps Android API
8. To create an API key for Maps click on Create credentials option and then select
the API key option

Click on the API key option to generate your API key. After clicking on this option your
API key will be generated
d) Explain multimedia framework in android. 4M

Page No: 5 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
Ans Multimedia Framework Proper
Explanation
4 marks

te
al
lc
le
a r.c
om
• The android multimedia system includes multimedia applications, multimedia
framework, OpenCore engine and hardware abstract for audio/video input/output
devices.
• The goal of the android multimedia framework is to provide a consistent interface
for Java services.
• The multimedia framework consists of several core dynamic libraries such as
libmediajni, libmedia, libmediaplayservice and so on
• Java classes call the Native C library Libmedia through Java JNI (Java Native
Interface).
• Libmedia library communicates with Media Server guard process through Android’s
Binder IPC (inter process communication) mechanism.
• Media Server process creates the corresponding multimedia service according to the
Java multimedia applications. The whole communication between Libmedia and
Media Server forms a Client/Server model.
• In Media Server guard process, it calls OpenCore multimedia engine to realize the
specific multimedia processing functions. And the OpenCore engine refers to the
PVPlayer and PVAuthor.

3. Attempt any THREE of the following: 12 M

a) Describe various installation steps of android studio and its environment. 4M

Ans Step 1: Correct

Page No: 6 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
Go to Android https://developer.android.com/studio to get the Android Studio executable or steps 4
zip file. marks

te
Step 2:

al
● Click on the Download Android Studio Button.
● Click on the “I have read and agree with the above terms and conditions” checkbox

lc
followed by the download button
● Click on the Save file button in the appeared prompt box and the file will start

le
downloading.

a r.c
Step 3:
After the downloading has finished, open the file from downloads and will prompt the
following dialog box. Click on next. In the next prompt, it’ll ask for a path for installation.

om
Choose a path and hit next.

Step 4:
It will start the installation, and once it is completed, it will be like the image shown below.
Step 5:
Once “Finish” is clicked, it will ask whether the previous settings need to be imported [if the
android studio had been installed earlier], or not. It is better to choose the ‘Don’t import
Settings option’. Click the OK button.

Step 6:
This will start the Android Studio. Meanwhile, it will be finding the available SDK
components.

Step 7:
After it has found the SDK components, it will redirect to the Welcome dialog box. Choose
Standard and click on Next. Now choose the theme, whether the Light theme or the Dark
one. The light one is called the IntelliJ theme whereas the dark theme is called Dracula.
Choose as required. Click on the Next button.

Step 8:
Now it is time to download the SDK components. Click on Finish. Components begin to
download let it complete. The Android Studio has been successfully configured. Now it’s
time to launch and build apps. Click on the Finish button to launch it.

Step 9:
Click on Start a new Android Studio project to build a new app.

b) Explain Gridview with its attributes with suitable example. 4M

Page No: 7 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
Ans GridView : (1 M for
explanation
Android GridView shows items in two-dimensional scrolling grid (rows & columns) and the of

te
grid items are not necessarily predetermined but they automatically inserted to the layout GridView,1

al
using a ListAdapter. M for
explaining

lc
GridView Attributes
attributes, 2

le
Following are the important attributes specific to GridView – M example)

a
[any two

r.c
attributes
Sr.No Attribute & Description should be
considered

om
1 android:id
for 1 M,
This is the ID which uniquely identifies the layout. any valid
example of
2 android:columnWidth GridView
for 2 M]
This specifies the fixed width for each column. This could be in px, dp,
sp, in, or mm.
3 android:gravity
Specifies the gravity within each cell. Possible values are top, bottom,
left, right, center, center_vertical, center_horizontal etc.
4 android:horizontalSpacing
Defines the default horizontal spacing between columns. This could be
in px, dp, sp, in, or mm.
5 android:numColumns
Defines how many columns to show. May be an integer value, such as
"100" or auto_fit which means display as many columns as possible to
fill the available space.
6 android:stretchMode
Defines how columns should stretch to fill the available empty space, if
any. This must be either of the values −
• none − Stretching is disabled.
• spacingWidth − The spacing between each column is stretched.
• columnWidth − Each column is stretched equally.
• spacingWidthUniform − The spacing between each column is
uniformly stretched..

Page No: 8 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
7 android:verticalSpacing
Defines the default vertical spacing between rows. This could be in px,

te
dp, sp, in, or mm.

al
lc
activity_main.xml Code :

le
<?xml version="1.0" encoding="utf-8"?>

a
<GridView xmlns:android="http://schemas.android.com/apk/res/android"

r.c
xmlns:app="http://schemas.android.com/apk/res-auto"

om
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp"
tools:context=".MainActivity">
</GridView>

activity_listview.xml code :
<?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">
<Button
android:id="@+id/btn"
android:layout_width="fill_parent"

Page No: 9 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
android:layout_height="wrap_content"
android:layout_gravity="center" />

te
</LinearLayout>

al
lc
MainActivity.java

le
package com.example.myapplication.gridviewbuttons;

a r.c
import android.os.Bundle;
import android.widget.ArrayAdapter;

om
import android.widget.GridView;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
GridView gridview;
String arr[] = new String[15];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gridview = findViewById(R.id.gridview);
for (int i = 0; i < 15; i++) {
arr[i] = Integer.toString(i + 1);
}
ArrayAdapter<String> ad = new ArrayAdapter<String>(this, R.layout.activity_listview,
R.id.btn, arr);
gridview.setAdapter(ad);
}
}

c) Explain text to speech conversion technique in android 4M

Ans Text to Speech converts the text written on the screen to speech like you have written “Hello Proper
World” on the screen and when you press the button it will speak “Hello World”. Text-to- explanation
speech is commonly used as an accessibility feature to help people who have trouble reading
Page No: 10 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
on-screen text, but it’s also convenient for those who want to be read too. This feature has

sb
4 marks
come out to be a very common and useful feature for the users.

te
In android, by using TextToSpeech class we can easily convert our text into voice and it

al
supports different types of speaking languages. We can choose the speaking language based
on our requirements in the android application.

lc
The android TextToSpeech instance can only be used to synthesize text once it has

le
completed its initialization so implement TextToSpeech.

a
OnInitListener to notify the completion of initialization. During the initialization, we can set

r.c
the audio pitch rate, audio speed, type of language to speak, etc. based on our requirements.

om
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns: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:orientation="vertical"
android:layout_margin="30dp"
tools:context=".MainActivity">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Text"
android:layout_marginBottom="20dp"
android:hint="Enter your text"
android:gravity="center"
android:textSize="16dp"/>

Page No: 11 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
<Button

te
android:layout_width="wrap_content"

al
android:id="@+id/btnText"

lc
android:layout_height="wrap_content"

le
android:text="Click"

a r.c
android:layout_gravity="center"/>

om
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="70dp"
android:gravity="center_horizontal"
android:text="MobileApplicationDevelopment"
android:textSize="36sp" />

</LinearLayout>

MainActivity.java
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import java.util.Locale;

Page No: 12 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
public class MainActivity extends AppCompatActivity {

te
EditText Text;

al
Button btnText;

lc
TextToSpeech textToSpeech;

le
@Override

a r.c
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

om
setContentView(R.layout.activity_main);

Text = findViewById(R.id.Text);
btnText = findViewById(R.id.btnText);

textToSpeech = new TextToSpeech(getApplicationContext(), new


TextToSpeech.OnInitListener() {
@Override
public void onInit(int i) {
if(i!=TextToSpeech.ERROR){
// To Choose language of speech
textToSpeech.setLanguage(Locale.UK);
}
}
});

btnText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

textToSpeech.speak(Text.getText().toString(),TextToSpeech.QUEUE_FLUSH,null);
}

Page No: 13 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
});

te
}

al
}

lc
d) Describe steps for deploying android application on Google Play Store. 4M

le
a
Ans Step 1: Create a Developer Account Correct
Before you can publish any app on Google Play, you need to create a Developer Account.

r.c
steps 4
You can easily sign up for one using your existing Google Account. You’ll need to pay a marks
one-time registration fee of $25 using your international credit or debit card. It can take

om
up to 48 hours for your registration to be fully processed.

Step 2: Plan to Sell? Link Your Merchant Account


If you want to publish a paid app or plan to sell in-app purchases, you need to create a
payments center profile, i.e. a merchant account. A merchant account will let you manage
your app sales and monthly payouts, as well as analyze your sales reports right in your
Play Console.

Step 3: Create an App


Now you have create an application by clicking on 'Create Application'. Here you have
to select your app’s default language from the drop-down menu and then type in a title
for your app. The title of your app will show on Google Play after you’ve published.

Step 4: Prepare Store Listing


Before you can publish your app, you need to prepare its store listing. These are all the
details that will show up to customers on your app’s listing on Google Play. You not
necessarily complete it at once , you can always save a draft and revisit it later when
you’re ready to publish.
The information required for your store listing is divided into several categories such as
Product Details containing title, short and full description of the app, Your app’s title and
description should be written with a great user experience in mind. Use the right keywords,
but don’t overdo it. Make sure your app doesn’t come across as spam-y or promotional, or it
will risk getting suspended on the Play Store.
Graphic Assets where you can add screenshots, images, videos, promotional graphics,
and icons that showcase your app’s features and functionality.
Languages & Translations, Categorization where in category can be selected to which
your app belong to. Contact Details , Privacy Policy for apps that request access to sensitive
user data or permissions, you need to enter a comprehensive privacy policy that effectively
discloses how your app collects, uses, and shares that data.

Step 5: Upload APK to an App Release


Finally upload your app, by uploading APK file. Before you upload APK, you need to
create an app release. You need to select the type of release you want to upload your first
app version to. You can choose between an internal test, a closed test, an open test, and a
Page No: 14 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
production release. The first three releases allow you to test out your app among a select
group of users before you make it go live for everyone to access.

te
This is a safer option because you can analyze the test results and optimize or fix your
app accordingly if you need to before rolling it out to all users.

al
Once you create a production release, your uploaded app version will become accessible
to everyone in the countries you choose to distribute it in and click on ‘Create release.’

lc
le
Step 6: Provide an Appropriate Content Rating
If you don’t assign a rating to your app, it will be listed as ‘Unrated’. Apps that are

a
‘Unrated’ may get removed from Google Play.

r.c
To rate your app, you need to fill out a content rating questionnaire An appropriate
content rating will also help you get to the right audience, which will eventually improve

om
your engagement rates.

Step 7: Set Up Pricing & Distribution


Before you can fill out the details required in this step, you need to determine your app’s
monetization strategy. Once you know how your app is going to make money, you can go
ahead and set up your app as free or paid.
You can always change your app from paid to free later, but you cannot change a free app
to paid. For that, you’ll need to create a new app and set its price.

Step 8: Rollout Release to Publish Your App


The final step involves reviewing and rolling out your release after making sure you’ve
taken care of everything else.
Before you review and rollout your release, make sure the store listing, content rating,
and pricing and distribution sections of your app each have a green check mark next to
them.
Once you’re sure about the correctness of the details, select your app and navigate to
‘Release management’ – ‘App releases.’ You can always opt for reviews by clicking on
‘Review’ to be taken to the ‘Review and rollout release’ screen. Here, you can see if there
are any issues or warnings you might have missed out on.
Finally, select ‘Confirm rollout.’ This will also publish your app to all users in your target
countries on Google Play.

4. Attempt any THREE of the following: 12 M

a) Describe directory structure and its components. 4M

Ans The android project contains different types of app modules, source code files, and resource 1 M for
files. listing of
directory
1. Manifests Folder structure , 3
2. Java Folder M for
explanation
3. res (Resources) Folder )

Page No: 15 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
Drawable Folder
• Layout Folder

te
• Mipmap Folder

al
• Values Folder

lc
le
4. Gradle Scripts

a r.c
om
Manifests Folder
Manifests folder contains AndroidManifest.xml for creating our android application. This
file contains information about our application such as the Android version, metadata, states
package for Kotlin file, and other application components. It acts as an intermediator
between android OS and our application.
Java folder
The Java folder contains all the java source code (.java) files that we create during the app
development, including other Test files. If we create any new project using Java, by default
the class file MainActivity.java will be created.
Resource (res) folder
The resource folder is the most important folder because it contains all the non-code sources
like images, XML layouts, and UI strings for our android application.
res/drawable folder
It contains the different types of images used for the development of the application. We

Page No: 16 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
need to add all the images in a drawable folder for the application development.
res/layout folder

te
The layout folder contains all XML layout files which we used to define the user interface of

al
our application. It contains the activity_main.xml file

lc
res/mipmap folder

le
This folder contains launcher.xml files to define icons that are used to show on the home

a
screen. It contains different density types of icons depending upon the size of the device

r.c
such as hdpi, mdpi, xhdpi.
res/values folder

om
Values folder contains a number of XML files like strings, dimensions, colors, and style
definitions. One of the most important files is the strings.xml file which contains the
resources.
Gradle Scripts folder
Gradle means automated build system and it contains a number of files that are used to
define a build configuration that can be applied to all modules in our application. In
build.gradle (Project) there are buildscripts and in build.gradle (Module) plugins and
implementations are used to build configurations that can be applied to all our application
modules.

b) Develop an android application for Date and Time Picker. 4M

Ans activity_main.xml (2M for


Date Picker
<?xml version="1.0" encoding="utf-8"?> and 2M for
<RelativeLayout Time
Picker)
xmlns: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"
tools:context=".MainActivity">
<EditText
android:layout_width="200dp"
android:layout_height="wrap_content"
android:id="@+id/in_time"
android:layout_alignParentLeft="true"

Page No: 17 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
android:layout_alignParentStart="true" />
<Button

te
android:layout_width="wrap_content"

al
android:layout_height="wrap_content"

lc
android:text="SELECT TIME"

le
android:id="@+id/btn_time"

a r.c
android:layout_below="@+id/in_time"/>
</RelativeLayout>

om
MainActivity.java
package com.example.myapplication.timepickerwithspinnermode;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TimePicker;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity implements
View.OnClickListener {
Button btnTimePicker;
EditText txtTime;
private int mHour, mMinute;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnTimePicker=(Button)findViewById(R.id.btn_time);

Page No: 18 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
txtTime=(EditText)findViewById(R.id.in_time);
btnTimePicker.setOnClickListener(this);

te
}

al
@Override

lc
public void onClick(View v) {

le
if (v == btnTimePicker) {

a r.c
// Get Current Time
final Calendar c = Calendar.getInstance();

om
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
// Launch Time Picker Dialog
TimePickerDialog timePickerDialog = new TimePickerDialog(this,
new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay,
int minute) {
txtTime.setText(hourOfDay + ":" + minute);
}
}, mHour, mMinute, false);
timePickerDialog.show();
}
}
}
c) Explain property animation method to animate the properties of view object with example. 4M

Ans A property animation changes a property's (a field in an object) value over a specified length (2 M for
of time. To animate something, you specify the object property that you want to animate, explaining
such as an object's position on the screen, how long you want to animate it for, and what property
values you want to animate between. animation
method, 2
The property animation system lets you define the following characteristics of an animation: M for
example )
Duration: You can specify the duration of an animation. The default length is 300 ms.
Time interpolation: You can specify how the values for the property are calculated as a
Page No: 19 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
function of the animation's current elapsed time.
Repeat count and behavior: You can specify whether or not to have an animation repeat

te
when it reaches the end of a duration and how many times to repeat the animation. You can

al
also specify whether you want the animation to play back in reverse. Setting it to reverse
plays the animation forwards then backwards repeatedly, until the number of repeats is

lc
reached.

le
Animator sets: You can group animations into logical sets that play together or sequentially

a
or after specified delays.

r.c
Frame refresh delay: You can specify how often to refresh frames of your animation. The
default is set to refresh every 10 ms, but the speed in which your application can refresh

om
frames is ultimately dependent on how busy the system is overall and how fast the system
can service the underlying timer.

Strings.xml
<resources>
<string name="app_name">Animation</string>
<string name="blink">BLINK</string>
<string name="fade">FADE</string>
<string name="move">MOVE</string>
</resources>

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<ImageView

Page No: 20 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
android:id="@+id/imageview"
android:layout_width="200dp"

te
android:layout_height="200dp"

al
android:layout_centerHorizontal="true"

lc
android:layout_marginTop="40dp"

le
android:contentDescription="@string/app_name"

a r.c
android:src="@drawable/image" />

om
<LinearLayout
android:id="@+id/linear1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/imageview"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:weightSum="3">

<Button
android:id="@+id/BTNblink"
style="@style/TextAppearance.AppCompat.Widget.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:padding="3dp"
android:text="@string/blink"
android:textColor="@color/white" />

Page No: 21 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
<Button

te
android:id="@+id/BTNfade"

al
style="@style/TextAppearance.AppCompat.Widget.Button"

lc
android:layout_width="0dp"

le
android:layout_height="wrap_content"

a r.c
android:layout_margin="10dp"
android:layout_weight="1"

om
android:padding="3dp"
android:text="@string/fade"
android:textColor="@color/white" />

<Button
android:id="@+id/BTNmove"
style="@style/TextAppearance.AppCompat.Widget.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:padding="3dp"
android:text="@string/move"
android:textColor="@color/white" />

</LinearLayout>

</RelativeLayout>

1) Blink Animation

Page No: 22 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

te
<alpha android:fromAlpha="0.0"

al
android:toAlpha="1.0"

lc
android:interpolator="@android:anim/accelerate_interpolator"

le
android:duration="500"

a r.c
android:repeatMode="reverse"
android:repeatCount="infinite"/>

om
</set>
2) Fade Animation
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<alpha
android:duration="1000"
android:fromAlpha="0"
android:toAlpha="1" />
<alpha
android:duration="1000"
android:fromAlpha="1"
android:startOffset="2000"
android:toAlpha="0" />
</set>
3) Move Animation
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">

Page No: 23 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
<translate

te
android:fromXDelta="0%p"

al
android:toXDelta="75%p"

lc
android:duration="700" />

le
</set>

a r.c
MainActivity.java
import androidx.appcompat.app.AppCompatActivity;

om
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {

ImageView imageView;
Button blinkBTN, fadeBTN, moveBTN;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageview);
blinkBTN = findViewById(R.id.BTNblink);
fadeBTN = findViewById(R.id.BTNfade);
moveBTN = findViewById(R.id.BTNmove);

Page No: 24 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
blinkBTN.setOnClickListener(new View.OnClickListener() {
@Override

te
public void onClick(View v) {

al
// To add blink animation

lc
Animation animation =

le
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink_animation);

a
imageView.startAnimation(animation);

r.c
}

om
});

fadeBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add fade animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_animation);
imageView.startAnimation(animation);
}
});
moveBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add move animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move_animation);
imageView.startAnimation(animation);
}
});
}
}

Page No: 25 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
d) Describe permissions required for android application development. 4M

Ans The Android security model is primarily based on a sandbox and permission mechanism. (2 Marks

te
Each application is running in a specific Dalvik virtual machine with a unique user ID for two
permission

al
assigned to it, which means the application code runs in isolation from the code of all other
applications. Therefore, one application has not granted access to other applications’ files. explanation

lc
)
Android application has been signed with a certificate with a private key Know the owner of

le
the application is unique. This allows the author of the application will be identified if

a
needed. When an application is installed in the phone is assigned a user ID, thus avoiding it

r.c
from affecting it other applications by creating a sandbox for it. This user ID is permanent
on which devices and applications with the same user ID are allowed to run in a single

om
process. This is a way to ensure that a malicious application has Cannot access /
compromise the data of the genuine application. It is mandatory for an application to list all
the resources it will Access during installation. Terms are required of an application, in the
installation process should be user-based or interactive Check with the signature of the
application.
Declaring and Using Permissions
The purpose of a permission is to protect the privacy of an Android user. Android apps must
request permission to access sensitive user data (such as contacts and SMS), as well as
certain system features (such as camera and internet). Depending on the feature, the system
might grant the permission automatically or might prompt the user to approve the request.
Permissions are divided into several protection levels. The protection level affects whether
runtime permission requests are required. There are three protection levels that affect third-
party apps: normal, signature, and dangerous permissions.
Normal permissions cover areas where your app needs to access data or resources outside
the app’s sandbox, but where there’s very little risk to the user’s privacy or the operation of
other apps. For example, permission to set the time zone is a normal permission. If an app
declares in its manifest that it needs a normal permission, the system automatically grants
the app that permission at install time. The system doesn’t prompt the user to grant normal
permissions, and users cannot revoke these permissions.
Signature permissions: The system grants these app permissions at install time, but only
when the app that attempts to use permission is signed by the same certificate as the app that
defines the permission.
Dangerous permissions: Dangerous permissions cover areas where the app wants data or
resources that involve the user’s private information, or could potentially affect the user’s
stored data or the operation of other apps. For example, the ability to read the user’s contacts
is a dangerous permission. If an app declares that it needs a dangerous permission, the user
must explicitly grant the permission to the app. Until the user approves the permission, your
app cannot provide functionality that depends on that permission. To use a dangerous
permission, your app must prompt the user to grant permission at runtime. For more details
about how the user is prompted, see Request prompt for dangerous permission.

Page No: 26 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
e) Develop an android application to show current location of an user's car 4M

te
Ans activity_maps.xml (2 M for

al
xml code, 1
<fragment xmlns:android="http://schemas.android.com/apk/res/android" M java

lc
xmlns:map="http://schemas.android.com/apk/res-auto" code,

le
1 M for
xmlns:tools="http://schemas.android.com/tools" permissions

a
)

r.c
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"

om
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="example.com.mapexample.MapsActivity" />

MapsActivity.java
import android.os.Build;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;

import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.location.LocationServices;

import android.location.Location;
import android.Manifest;

Page No: 27 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
import android.content.pm.PackageManager;
import android.support.v4.content.ContextCompat;

te
import com.google.android.gms.common.ConnectionResult;

al
import com.google.android.gms.location.LocationListener;

lc
import com.google.android.gms.location.LocationRequest;

le
a r.c
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,

om
LocationListener,GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener{

private GoogleMap mMap;


Location mLastLocation;
Marker mCurrLocationMarker;
GoogleApiClient mGoogleApiClient;
LocationRequest mLocationRequest;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);

@Override

Page No: 28 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;

te
al
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {

lc
if (ContextCompat.checkSelfPermission(this,

le
Manifest.permission.ACCESS_FINE_LOCATION)

a r.c
== PackageManager.PERMISSION_GRANTED) {
buildGoogleApiClient();

om
mMap.setMyLocationEnabled(true);
}
}
else {
buildGoogleApiClient();
mMap.setMyLocationEnabled(true);
}

}
protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API).build();
mGoogleApiClient.connect();
}

@Override
public void onConnected(Bundle bundle) {

mLocationRequest = new LocationRequest();

Page No: 29 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
mLocationRequest.setInterval(1000);
mLocationRequest.setFastestInterval(1000);

te
al
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY)
;

lc
le
if (ContextCompat.checkSelfPermission(this,

a
Manifest.permission.ACCESS_FINE_LOCATION)

r.c
== PackageManager.PERMISSION_GRANTED) {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,

om
mLocationRequest, this);
}

@Override
public void onConnectionSuspended(int i) {

@Override
public void onLocationChanged(Location location) {

mLastLocation = location;
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
//Place current location marker
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Position");
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));

Page No: 30 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
mCurrLocationMarker = mMap.addMarker(markerOptions);

te
//move map camera

al
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

lc
mMap.animateCamera(CameraUpdateFactory.zoomTo(11));

le
a r.c
//stop location updates
if (mGoogleApiClient != null) {

om
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient,
this);
}
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
}
}
Add the following user-permission in AndroidManifest.xml file.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

Note: only the permission line can be written , no entire code is required for manifest file.

5. Attempt any TWO of the following: 12 M

a) Design a employee registration form using UI component. 6M

Ans activity_main.xml (Any


<?xml version="1.0" encoding="utf-8"?> Correct
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" Design -
XML file:
xmlns:tools="http://schemas.android.com/tools"
6M)
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
Page No: 31 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
<TextView

te
android:text="Employee Registration Form"
android:layout_width="wrap_content"

al
android:layout_height="wrap_content"

lc
android:layout_alignParentTop="true"

le
android:layout_centerHorizontal="true"
android:id="@+id/textView"

a
android:gravity="center"

r.c
android:textSize="20dp"
android:textColor="#000000"/>

om
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="ID"
android:id="@+id/editid"
android:layout_below="@+id/textView"/>

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Name"
android:id="@+id/editname"
android:layout_below="@+id/editid"/>

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Mobile No."
android:id="@+id/editmobile"
android:layout_below="@+id/editname"/>

<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Address"
android:lines="3"
android:id="@+id/editaddress"
android:layout_below="@+id/editmobile"/>

<EditText
android:layout_width="fill_parent"
Page No: 32 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
android:layout_height="wrap_content"
android:hint="Pin Code"

te
android:id="@+id/editpincode"
android:layout_below="@+id/editaddress"/>

al
lc
<Button

le
android:text="Submit Details"
android:layout_width="fill_parent"

a
android:layout_height="wrap_content"

r.c
android:layout_below="@+id/editpincode"
android:layout_centerHorizontal="true"

om
android:id="@+id/button" />
</RelativeLayout>

b) Develop an android application for taking student feedback with database 6M


connectivity.
Ans activity_main.xml (Any
correct code
<?xml version="1.0" encoding="utf-8"?> can be
consider
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" 3 Marks for
xmlns:tools="http://schemas.android.com/tools" XML file
android:layout_width="match_parent" and 3 marks
android:layout_height="match_parent" for Java
file)
android:orientation="vertical"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Student Feedback Form" />

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name"
android:id="@+id/editname"/>

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Roll No."

Page No: 33 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
android:id="@+id/editrollno"/>

te
<EditText
android:layout_width="match_parent"

al
android:layout_height="wrap_content"

lc
android:hint="Class"

le
android:id="@+id/editclass"/>

a
<EditText

r.c
android:layout_width="match_parent"
android:layout_height="wrap_content"

om
android:hint="Enter your Feedback"
android:lines="3"
android:id="@+id/editfeedback"/>

<Button
android:text="Submit Feedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:id="@+id/button" />
</LinearLayout>

MapsActivity.java

package com.example.feedback;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


SQLiteDatabase sqLiteDatabaseObj;
Button submitBtn;
EditText std_name, std_rollno, std_class, std_feedback;
String sname, srollno, sclass, sfeedback, sql_query;
@Override
Page No: 34 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

te
setContentView(R.layout.activity_main);
submitBtn = (Button)findViewById(R.id.button);

al
std_name = (EditText)findViewById(R.id.editname);

lc
std_rollno = (EditText)findViewById(R.id.editrollno);

le
std_class = (EditText)findViewById(R.id.editclass);
std_class = (EditText)findViewById(R.id.editfeedback);

a r.c
submitBtn.setOnClickListener(new View.OnClickListener() {
@Override

om
public void onClick(View view) {
sqLiteDatabaseObj = openOrCreateDatabase("FeedbaseDataBase",
Context.MODE_PRIVATE, null);
sqLiteDatabaseObj.execSQL("CREATE TABLE IF NOT EXISTS
Student(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name
VARCHAR, rollno VARCHAR, class VARCHAR, feedback VARCHAR);");
sname = std_name.getText().toString();
srollno = std_rollno.getText().toString() ;
sclass = std_class.getText().toString();
sfeedback = std_class.getText().toString();
sql_query = "INSERT INTO Student (name, rollno, class, feedback)
VALUES('"+sname+"', '"+srollno+"', '"+sclass+"', '"+sfeedback+"')";
sqLiteDatabaseObj.execSQL(sql_query);
Toast.makeText(getApplicationContext(), "Feedback Submitted
Successfully", Toast.LENGTH_LONG).show();
}
});

}
}

c) Explain Geocoding and Reverse Geocoding with suitable example. 6M

Ans Geocoding is the process of transforming a street address or other description of a (Geocoding ,
location into a (latitude, longitude) coordinate. Reverse
Geocoding
Reverse geocoding is the process of transforming a (latitude, longitude) coordinate into a Explanation :
(partial) address. 3 M,
Example :
The amount of detail in a reverse geocoded location description may vary, for example 3M)
one might contain the full street address of the closest building, while another might
contain only a city name and postal code.

Page No: 35 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
The Geocoder class is used for handling geocoding and reverse geocoding.

te
activity_maps.xml

al
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"

lc
xmlns:tools="http://schemas.android.com/tools"

le
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"

a
android:layout_width="match_parent"

r.c
android:layout_height="match_parent"
tools:context="example.com.mapexample.MapsActivity">

om
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<EditText
android:layout_width="248dp"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:hint="Search Location" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="searchLocation"
android:text="Search" />

</LinearLayout>

</fragment>

AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

MapsActivity.java
package example.com.mapexample;

import android.location.Address;
import android.location.Geocoder;
import android.os.Build;
import android.support.v4.app.FragmentActivity;
Page No: 36 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
import android.os.Bundle;

import com.google.android.gms.common.api.GoogleApiClient;

te
import com.google.android.gms.maps.CameraUpdateFactory;

al
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;

lc
import com.google.android.gms.maps.SupportMapFragment;

le
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;

a
import com.google.android.gms.maps.model.Marker;

r.c
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.location.LocationServices;

om
import android.location.Location;
import android.Manifest;
import android.content.pm.PackageManager;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;

import java.io.IOException;
import java.util.List;

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback,


LocationListener,GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener{

private GoogleMap mMap;


Location mLastLocation;
Marker mCurrLocationMarker;
GoogleApiClient mGoogleApiClient;
LocationRequest mLocationRequest;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be
used.
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager()

.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);

Page No: 37 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
}

te
@Override

al
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;

lc
le
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(this,

a
Manifest.permission.ACCESS_FINE_LOCATION)

r.c
== PackageManager.PERMISSION_GRANTED) {
buildGoogleApiClient();

om
mMap.setMyLocationEnabled(true);
}
}
else {
buildGoogleApiClient();
mMap.setMyLocationEnabled(true);
}

}
protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API).build();
mGoogleApiClient.connect();
}

@Override
public void onConnected(Bundle bundle) {

mLocationRequest = new LocationRequest();


mLocationRequest.setInterval(1000);
mLocationRequest.setFastestInterval(1000);

mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {

LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,
mLocationRequest, this);
}

@Override
public void onConnectionSuspended(int i) {

Page No: 38 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
}

te
@Override

al
public void onLocationChanged(Location location) {

lc
mLastLocation = location;

le
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();

a
}

r.c
//Place current location marker
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());

om
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Position");

markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
mCurrLocationMarker = mMap.addMarker(markerOptions);

//move map camera


mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(11));

//stop location updates


if (mGoogleApiClient != null) {

LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
}

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {

public void searchLocation(View view) {


EditText locationSearch = (EditText) findViewById(R.id.editText);
String location = locationSearch.getText().toString();
List<Address> addressList = null;

if (location != null || !location.equals("")) {


Geocoder geocoder = new Geocoder(this);
try {
addressList = geocoder.getFromLocationName(location, 1);

} catch (IOException e) {
e.printStackTrace();
}

Page No: 39 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
Address address = addressList.get(0);
LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
mMap.addMarker(new MarkerOptions().position(latLng).title(location));

te
mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));

al
Toast.makeText(getApplicationContext(),address.getLatitude()+"
"+address.getLongitude(),Toast.LENGTH_LONG).show();

lc
}

le
}

a
}

r.c
6. Attempt any TWO of the following: 12 M

om
a) Design an android application to show the list of paired devices by Bluetooth. 6M

Ans activity_main.xml Layout file


<?xml version="1.0" encoding="utf-8"?> : 2M
<RelativeLayout Java File :
xmlns:android="http://schemas.android.com/apk/res/android" 3M
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" Manifest
file : 1M
android:layout_height="match_parent"
tools:context=".MainActivity"
android:transitionGroup="true">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="List all Paired devices"
android:onClick="list"
android:id="@+id/button1"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Paired devices:"
android:id="@+id/textView1"
android:textColor="#ff34ff06"
android:textSize="25dp"
android:layout_below="@+id/button1" />

<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listView"

Page No: 40 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
android:layout_alignParentBottom="true"
android:layout_below="@+id/textView1" />

te
</RelativeLayout>

al
AndroidManifest.xml

lc
<?xml version="1.0" encoding="utf-8"?>

le
<manifest xmlns:androclass="http://schemas.android.com/apk/res/android"
package="com.example.bluetooth"

a
android:versionCode="1"

r.c
android:versionName="1.0" >

om
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-
permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=" in.org.msbte.bluetooth.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

MainActivity.java

package in.org.msbte.bluetooth;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;

import android.content.Intent;
import android.view.View;

import android.widget.ArrayAdapter;
import android.widget.Button;
Page No: 41 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
import android.widget.ListView;

import android.widget.Toast;

te
import java.util.ArrayList;

al
import java.util.Set;

lc
public class MainActivity extends AppCompatActivity {

le
Button b1;
private BluetoothAdapter BA;

a
private Set<BluetoothDevice>pairedDevices;

r.c
ListView lv;

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

b1 = (Button) findViewById(R.id.button1);

BA = BluetoothAdapter.getDefaultAdapter();
lv = (ListView)findViewById(R.id.listView);
}

public void list(View v){


pairedDevices = BA.getBondedDevices();

ArrayList list = new ArrayList();

for(BluetoothDevice bt : pairedDevices) list.add(bt.getName());


Toast.makeText(getApplicationContext(), "Showing Paired
Devices",Toast.LENGTH_SHORT).show();

final ArrayAdapter adapter = new


ArrayAdapter(this,android.R.layout.simple_list_item_1, list);

lv.setAdapter(adapter);
}
}

b) Develop an android application for sending Short Message Service (SMS). 6M

Ans activity_main.xml (XML file 3


marks Java
<?xml version="1.0" encoding="utf-8"?> file 3
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" Marks)
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
Page No: 42 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
<TextView
android:id="@+id/fstTxt"
android:layout_width="wrap_content"

te
android:layout_height="wrap_content"

al
android:layout_marginLeft="100dp"
android:layout_marginTop="150dp"

lc
android:text="Mobile No" />

le
<EditText
android:id="@+id/mblTxt"

a
android:layout_width="wrap_content"

r.c
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"

om
android:ems="10"/>

<TextView
android:id="@+id/secTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message"
android:layout_marginLeft="100dp" />
<EditText
android:id="@+id/msgTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:ems="10" />
<Button
android:id="@+id/btnSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:text="Send SMS" />
</LinearLayout>

MainActivity.java

package in.org.msbte.sendsmsexample;
import android.content.Intent;
import android.net.Uri;
import android.provider.Telephony;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

Page No: 43 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
public class MainActivity extends AppCompatActivity {

private EditText txtMobile;

te
private EditText txtMessage;

al
private Button btnSms;
@Override

lc
protected void onCreate(Bundle savedInstanceState) {

le
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

a
txtMobile = (EditText)findViewById(R.id.mblTxt);

r.c
txtMessage = (EditText)findViewById(R.id.msgTxt);
btnSms = (Button)findViewById(R.id.btnSend);

om
btnSms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try{
SmsManager smgr = SmsManager.getDefault();

smgr.sendTextMessage(txtMobile.getText().toString(),null,txtMessage.getText().toString(),null,null);
Toast.makeText(MainActivity.this, "SMS Sent Successfully",
Toast.LENGTH_SHORT).show();
}
catch (Exception e){
Toast.makeText(MainActivity.this, "SMS Failed to Send, Please try again",
Toast.LENGTH_SHORT).show();
}
}
});
}
}
c) Explain how linear and frame layout is used to design an android application with 6M
suitable example.
Ans LinearLayout (2 M : For
each layout
• Android LinearLayout is a view group that aligns all children in either vertically explanation,
or horizontally. 1 M for
each layout
• Linear layout in Android allow us to arrange components horizontally in a single
example)
column or
vertically in a single row.
• Vertically or horizontally direction depends on attribute android: orientation.
• Linear layout is simple and easy to use, it creates a scroll bar if the length of the
window exceeds the length of the screen.
• Linear Layout are one of the simplest and common type of layouts used by
Android developers to keep controls within their interfaces. The linear layout
works as much as its name implies, it organizes the controls either a vertical or
horizontal pattern.
• When the layout’s orientation is set to vertical, all child controls within
Page No: 44 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
organized in a single column, and when the layout’s orientation is set to

sb
horizontal, all child controls within in single row.

te
Example

al
lc
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutandroid:layout_width="368dp"

le
android:layout_height="495dp"

a
xmlns:tools="http://schemas.android.com/tools"

r.c
android:orientation="vertical"
tools:layout_editor_absoluteX="8dp"

om
tools:layout_editor_absoluteY="8dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:id="@+id/button5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button1" />
<Button
android:id="@+id/button6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button2" />
<Button
android:id="@+id/button7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button3" />
<Button
android:id="@+id/button8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button4" />
</LinearLayout>

Frame Layout

• Frame Layout is designed to block out an area on the screen to display a single item.
Generally, FrameLayout should be used to hold a single child view, because it can be
difficult to organize child views in a way that's scalable to different screen sizes without
the children overlapping each other.
Page No: 45 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
• Frame layouts are one of the simplest layout types used to organize controls within the
user interface of an Android application. The purpose of FrameLayout is to allocate an

te
area of screen.
• Frame layouts are one of the most efficient types of layouts used by Android developers

al
to organize view controls. They are used less often than some other layouts, simply

lc
because they are generally used to display only one view, or views which overlap.
• The frame layout is often used as a container layout, as it generally only has a single

le
child view (often another layout, used to organize more than one view).

a
Example

r.c
om
<?xml version="1.0" encoding="utf-8"?>
<FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/framelayout"
android:layout_width="200dp"
android:layout_height="300dp"
tools:context=".MainActivity">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="90dp"
android:layout_marginLeft="20dp"
android:text="Button"/>
<TextView
android:layout_width="100dp"
android:layout_height="50dp"
android:textSize="20sp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:background="@color/colorPrimary"
android:textColor="#fff"
android:text="I am TextView" />
</FrameLayout

Page No: 46 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)

m
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

sb
te
al
lc
le
a r.c
om

Page No: 47 | 47
lOMoARcPSD|46833019

MAD-W-23 - Mobile Application Development 22617 winter


2023 model answer paper.
MAD 22617
Computer Engineering (Anjuman-I-Islam’s A. R. Kalsekar Polytechnic)

Scan to open on Studocu

Studocu is not sponsored or endorsed by any college or university


Downloaded by Nitesh Poojari ([email protected])
lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER – 2023 EXAMINATION
Model Answer Paper

Subject Name: Mobile Application Development Subject Code: 22617


Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not applicable for
subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The figures
drawn by candidate and model answer may vary. The examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may vary and
there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based on
candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual (English +
Marathi) medium is introduced at first year of AICTE diploma Programme from academic year 2021-2022. Hence if
the students in first year (first and second semesters) write answers in Marathi or bilingual language (English
+Marathi), the Examiner shall consider the same and assess the answer based on matching of concepts with model
answer.

Q. Su Answer Marking Scheme


No b
. Q.
N.

1 Attempt any FIVE of the following: 10 M

a) List all tools and software’s required for developing an android 2M


application.

Ans  Android Studio Any 4 tools


 ADB (Android Debug Bridge)
One tool for ½ Mark
 AVD Manager
 Eclipse 2M
 Fabric
 FlowUp
 GameMaker: Studio
 Genymotion
 Gradle
 IntelliJ IDEA
b) Define emulator. 2M
Ans An Android emulator is a tool that creates virtual Android devices on your Correct Definition 2
computer. The emulator lets you prototype, develop and test Android applications M
without using a physical device.

Page No: 1 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
c) List any four attributes of layout. 2M
Ans  android:id Any 4 attributes
 android:layout_width
One attribute for ½
 android:layout_height
Mark
 android:layout_margin
 android:layout_marginTop 2M
 android:layout_marginBottom
 android:layout_marginLeft
 android:layout_marginRight
 android:background
d) Define Geocoding and Reverse Geocoding. 2M

Ans Geocoding : Geocoding:1 M


Geocoding is the process of transforming a street address or other description of a Reverse
location into a (latitude, longitude) coordinate. Geocoding:1 M

Reverse Geocoding :
Reverse geocoding is the process of transforming a (latitude, longitude) coordinate
into a (partial) address.

e) State intent. List types of intent. 2M

Ans Intent is the message that is passed between components such as activities. Definition 1 M
Android uses Intent for communicating between the components of an Application Types Listing 1 M
and also from one application to another application.
Types:
 Explicit Intent
 Implicit Intent
f) Write difference between toggle button and radio button. 2M

Ans For 2 points : 2 M

Toggle button Radio button

1. Toggle Button can be used to 1. Radio Buttons are used to choose a


display checked/unchecked single option from a list
(On/Off) state on the button.
2. For ON/OFF state two labels can 2. There is only one label for radio
be assign. button.

Page No: 2 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
g) Define: 2M
i)Fragment
ii) Broadcast receiver
Ans Fragment: Fragment :1 M
Fragment is the part of activity, it is also known as sub-activity.
Broadcast receiver :
1M
Broadcast receiver:

A broadcast receiver is a dormant component of the Android system. The Broadcast


Receiver’s job is to pass a notification to the user, in case a specific event occurs.

2. Attempt any THREE of the following: 12 M


a) Explain relative layout with all its attributes. 4M
Ans In Relative Layout we need to specify the position of child views relative to each Explanation 1 M
other or relative to the parent. In case if we didn’t specify the position of child views,
by default all child views are positioned to top-left of the layout. Any three Attributes
with description- 3
Attributed of Relative Layout: M

Attribute Description

layout_alignParentTop If it specified “true”, the top edge of view will


match the top edge of parent.

layout_alignParentBottom If it specified “true”, the bottom edge of view


will match the bottom edge of parent.

layout_alignParentLeft If it specified “true”, the left edge of view will


match the left edge of parent.

layout_alignParentRight If it specified “true”, the right edge of view


will match the right edge of parent.

layout_centerInParent If it specified “true”, the view will be aligned


to center of parent.

layout_centerHorizontal If it specified “true”, the view will be


horizontally centre aligned within its parent.

layout_centerHorizontal If it specified “true”, the view will be

Page No: 3 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

vertically centre aligned within its parent.

layout_above It accepts another sibling view id and places


the view above the specified view id.

layout_below It accepts another sibling view id and places


the view below the specified view id.

layout_toLeftOf It accepts another sibling view id and places


the view left of the specified view id.

layout_toRightOf It accepts another sibling view id and places


the view right of the specified view id.

layout_toStartOf It accepts another sibling view id and places


the view to start of the specified view id.

layout_toEndOf It accepts another sibling view id and places


the view to end of the specified view id.

b) Explore all steps to install Android studio and SDK 4M


Ans Pre-Installation Check List Android studio
1. Before installing Android SDK, there is need to install Java Development Kit installation 2 M
(JDK). Ensure that JDK is at or above 1.8.
SDK installation
2. Uninstall older version(s) of "Android Studio" and "Android SDK", if any. 2M
We need to install two packages:
1. Android Studio (IDE), which is an Integrated Development
Environment (IDE)
2. Android SDK (Software Development Kit) for developing and
running Android apps.

Steps to install Android studio:

Download Android Studio

1. Click Download Android Studio. The Terms and Conditions page with
the Android Studio License Agreement opens.
2. Read the License Agreement.
3. At the bottom of the page, if you agree with the terms and conditions,
select the I have read and agree with the above terms and
Page No: 4 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
conditions checkbox.
4. Click Download Android Studio to start the download.
5. When prompted, save the file to a location where you can easily locate it,
such as the Downloads folder.
6. Wait for the download to complete.

Install Android Studio


a. Open the folder where you downloaded and saved the Android Studio
installation file.
b. Double-click the downloaded file.
c. If you see a User Account Control dialog about allowing the installation to
make changes to your computer, click Yes to confirm the installation.
d. Click Next to start the installation.
e. Accept the default installation settings for all steps.
2. Click finish when installation is done.

Installing Android SDK

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

1. Click Tools > SDK Manager.


2. In the SDK Platforms tab, select Android Tiramisu Preview.
3. In the SDK Tools tab, select Android SDK Build.
4. Click OK to install the SDK.

c) Explain the need of Android Operating System. Also describe any four 4M
features of android.

Ans Need of Android Operating System Need : 2 M

 Zero/negligible development cost: Any 4 features : 4


M
The development tools like Android SDK, JDK, and Eclipse IDE etc. are free
to download for the android mobile application development.

 Open Source:

The Android OS is an open-source platform based on the Linux kernel and


multiple open-source libraries. In this way developers are free to contribute or
extend the platform as necessary for building mobile apps which run on
Page No: 5 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Android devices.

 Multi-Platform Support

In market, there are a wide range of hardware devices powered by the


Android OS, including many different phones and tablet. Even development
of android mobile apps can occur on Windows, Mac OS or Linux.

 Multi-Carrier Support

World wide a large number of telecom carriers like Airtel, Vodafone, Idea
Cellular, AT&T Mobility, BSNL etc. are supporting Android powered
phones.

 Open Distribution Model

Android Market place (Google Play store) has very few restrictions on the
content or functionality of an android app. So the developer can distribute
theirs app through Google Play store and as well other distribution channels
like Amazon’s app store.
Four features of android
1) Near Field Communication (NFC)

Most Android devices support NFC, which allows electronic devices to easily
interact across short distances.

2) Alternate Keyboards

Android supports multiple keyboards and makes them easy to install; the SwiftKey,
Skype, and 8pen apps all offer ways to quickly change up your keyboard style.

3) Infrared Transmission

The Android operating system supports a built-in infrared transmitter, allowing you
to use your phone or tablet as a remote control.

4) No-Touch Control

Using Android apps such as Wave Control, users can control their phones touch-free,
using only gestures.

5) Automation

The Tasker app controls the app permissions but also automate them

6) Wireless App Downloads

Using the Android Market or third-party options like AppBrain, we can download
apps on PC and then automatically sync them with Android, no plugging required.

Page No: 6 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
7) Storage and Battery Swap

Android phones also have unique hardware capabilities. Google’s OS makes it


possible to remove and upgrade your battery or to replace one that no longer holds a
charge

8) Custom Home Screens

While it’s possible to hack certain phones to customize the home screen, Android
comes with this capability from the get-go

9) Widgets

Apps are versatile, but sometimes you want information at a glance instead of having
to open an app and wait for it to load. Android widgets let you display just about any
feature you choose, right on the home screen—including weather apps, music
widgets, or productivity tools that helpfully remind you of upcoming meetings or
approaching deadlines.

d) Develop a program to add "Hello World" marker at (10 ,10) co- 4M


ordinates. Write only . java file.

Ans Activity_maps.xml Any correct logic


program 4 Marks
package com.example.googlemap;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class MapsActivity extends FragmentActivity implements


OnMapReadyCallback {

private GoogleMap mMap;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to
be used.
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}

@Override
public void onMapReady(GoogleMap googleMap) {
Page No: 7 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
mMap = googleMap;

// Add a marker in Sydney and move the camera


LatLng hello = new LatLng(10,10);
mMap.addMarker(new MarkerOptions().position(hello).title("Marker Hello
World"));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(mumbai,10F));
}
}

3. Attempt any THREE of the following: 12 M

a) Describe service life cycle with its diagram. 4M

Ans A service is an application component which runs without direst interaction with Explanation 2 M,
Diagram 2 M
the user in the background.
● Services are used for repetitive and potentially long running operations, i.e.,
Internet downloads, checking for new data, data processing, updating content
providers and the like.
● Service can either be started or bound we just need to call either startService() or
bindService() from any of our android components. Based on how our service
was started it will either be “started” or “bound”

Service Lifecycle:
1. Started
a. A service is started when an application component, such as an activity, starts it by
calling startService().
b. Now the service can run in the background indefinitely, even if the component that
started it is destroyed.
2. Bound
a. A service is bound when an application component binds to it by calling
bindService().
b. A bound service offers a client-server interface that allows components to interact
with the service, send requests, get results, and even do so across processes with
InterProcess Communication (IPC).
c. Like any other components service also has callback methods. These will be
invoked while the service is running to inform the application of its state.
Implementing these in our custom service would help you in performing the right

Page No: 8 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
operation in the right state.

d. There is always only a single instance of service running in the app. If you are
calling startService() for a single service multiple times in our application it just
invokes the onStartCommand() on that service. Neither is the service restarted
multiple times nor are its multiple instances created.
1. onCreate():
This is the first callback which will be invoked when any component starts the
service. If the same service is called again while it is still running this method
Won’t be invoked. Ideally one time setup and intializing should be done in this
callback.
2. onStartCommand() /startSetvice()
This callback is invoked when service is started by any component by calling
startService(). It basically indicates that the service has started and can now run
indefinetly.
3. onBind()
To provide binding for a service, you must implement the onBind() callback
method. This method returns an IBinder object that defines the programming
interface that clients can use to interact with the service.

Page No: 9 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
4. onUnbind()
This is invoked when all the clients are disconnected from the service.

5. onRebind()
This is invoked when new clients are connected to the service. It is called after
onRebind

6. onDestroy()
This is a final clean up call from the system. This is invoked just before the
service is being destroyed.

b) Elaborate Android Security Model. 4M


Ans  The Android security model is primarily based on a sandbox and permission 2 M for explanation
mechanism. , 2 M for explaining
permissions, any 2
 Each application is running in a specific Dalvik virtual machine with a unique permissions
user ID assigned to it, which means the application code runs in isolation expected
from the code of all other applications.

 Therefore, one application has not granted access to other applications’ files.

 Android application has been signed with a certificate with a private key
Know the owner of the application is unique.

 This allows the author of the application will be identified if needed. When
an application is installed in the phone is assigned a user ID, thus avoiding it
from affecting it other applications by creating a sandbox for it.

 This user ID is permanent on which devices and applications with the same
user ID are allowed to run in a single process.

 This is a way to ensure that a malicious application has Cannot access /


compromise the data of the genuine application.

 It is mandatory for an application to list all the resources it will Access during
installation. Terms are required of an application, in the installation process
should be user-based or interactive Check with the signature of the
application

Declaring and Using Permissions


The purpose of a permission is to protect the privacy of an Android user.
Android apps must request permission to access sensitive user data (such as
contacts and SMS), as well as certain system features (such as camera and
internet). Depending on the feature, the system might grant the permission
automatically or might prompt the user to approve the request.
Permissions are divided into several protection levels. The protection level

Page No: 10 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
affects whether runtime permission requests are required. There are three
protection levels that affect third party apps: normal, signature, and
dangerous permissions.
Normal permissions: Normal permissions cover areas where your app needs
to access data or resources outside the app’s sandbox, but where there’s very
little risk to the user’s privacy or the operation of other apps. For example,
permission to set the time zone is a normal permission. If an app declares in
its manifest that it needs a normal permission, the system automatically
grants the app that permission at install time. The system doesn’t prompt the
user to grant normal permissions, and users cannot revoke these permissions.
Signature permissions: The system grants these app permissions at install
time, but only when the app that attempts to use permission is signed by the
same certificate as the app that defines the permission.
Dangerous permissions: Dangerous permissions cover areas where the app
wants data or resources that involve the user’s private information, or could
potentially affect the user’s stored data or the operation of other apps. For
example, the ability to read the user’s contacts is a dangerous permission. If
an app declares that it needs a dangerous permission, the user must explicitly
grant the permission to the app. Until the user approves the permission, your
app cannot provide functionality that depends on that permission. To use a
dangerous permission, your app must prompt the user to grant permission at
runtime. For more details about how the user is prompted, see Request
prompt for dangerous permission.

c) Write an xml file to create login page using Table Layout. 4M

Ans <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 M for correct


structure of Table
android:layout_width="match_parent" Layout , 2 M for
attributes
android:layout_height="match_parent"
android:background="#000"
android:orientation="vertical"
android:stretchColumns="1">
<TableRow android:padding="5dip">
<TextView
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_span="2"
android:gravity="center_horizontal"

Page No: 11 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:text="@string/loginForm"
android:textColor="#0ff"
android:textSize="25sp"
android:textStyle="bold" />
</TableRow>
<TableRow>
<TextView
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_marginLeft="10dp"
android:text="@string/userName"
android:textColor="#fff"
android:textSize="16sp" />
<EditText
android:id="@+id/userName"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:background="#fff"
android:hint="@string/userName"
android:padding="5dp"
android:textColor="#000" />
</TableRow>
<TableRow>
<TextView
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_marginLeft="10dp"

Page No: 12 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_marginTop="20dp"
android:text="@string/password"
android:textColor="#fff"
android:textSize="16sp" />
<EditText
android:id="@+id/password"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="#fff"
android:hint="@string/password"
android:padding="5dp"
android:textColor="#000" />
</TableRow>
<TableRow android:layout_marginTop="20dp">
<Button
android:id="@+id/loginBtn"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_span="2"
android:background="#0ff"
android:text="@string/login"
android:textColor="#000"
android:textSize="20sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>

Page No: 13 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
d) Develop an application to display analog Time Picker. Also display the 4M
selected time. (Write only . java file)
Ans MainActivity.java Code for display
time picker 2 M and
import android.os.Bundle;
display time 2 M
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TimePicker;
public class MainActivity extends AppCompatActivity {
TextView textview1;
TimePicker timepicker;
Button changetime;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textview1=(TextView)findViewById(R.id.textView1);
timepicker=(TimePicker)findViewById(R.id.timePicker);
//Uncomment the below line of code for 24 hour view
timepicker.setIs24HourView(true);
changetime=(Button)findViewById(R.id.button1);
textview1.setText(getCurrentTime());
changetime.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
textview1.setText(getCurrentTime());
}
});

Page No: 14 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}
public String getCurrentTime(){
String currentTime="Current Time:
"+timepicker.getCurrentHour()+":"+timepicker.getCurrentMinute();
return currentTime;
}
}

4. Attempt any THREE of the following: 12 M

a) Differentiate between JVM and DVM. (Any four points) 4M


Ans Any 4 points of
differences :1 M
DVM JVM each
It is Register based which is designed to It is Stack based.
run on low memory.

DVM uses its own byte code and runs JVM uses java byte code and runs
the “.Dex” file. From Android 2.2 SDK “.class” file having JIT (Just In Time).
Dalvik has got a Just in Time compiler

DVM has been designed so that a A single instance of JVM is shared with
device can run multiple instances of the multiple applications.
VM efficiently. Applications are given
their own instance

DVM supports the Android operating JVM supports multiple operating


system only. systems.

There is a constant pool for every It has a constant pool for every class.
application.

Here the executable is APK. Here the executable is JAR

b) Explain components of android directory structure. 4M

An The android project contains different types of app modules, source code files, and 1 M for each
s resource files. directory
Following are the components/ modules of android directory:

1) Manifests Folder
Manifests folder contains AndroidManifest.xml for creating our android
application. This file contains information about our application such as the

Page No: 15 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Android version, metadata, states package for Kotlin file, and other
application components. It acts as an intermediator between android OS and
our application.

2) Java folder
The Java folder contains all the java source code (.java) files that we create
during the app development, including other Test files.

3) Resource (res) folder


The resource folder is the most important folder because it contains all the
non-code sources like images, XML layouts, and UI strings for our android
application.

 res/drawable folder
It contains the different types of images used for the development of
the application. We need to add all the images in a drawable folder for
the application development.

 res/layout folder
The layout folder contains all XML layout files which we used to
define the user interface of our application. It contains the
activity_main.xml file.
 res/mipmap folder
This folder contains launcher.xml files to define icons that are used to
show on the home screen. It contains different density types of icons
depending upon the size of the device such as hdpi, mdpi, xhdpi.

 res/values folder
Values folder contains a number of XML files like strings,
dimensions, colors, and style definitions. One of the most important
files is the strings.xml file which contains the resources.

4) Gradle Scripts folder


Gradle means automated build system and it contains a number of files that
are used to define a build configuration that can be applied to all modules in
our application. In build.gradle (Project) there are buildscripts and in
build.gradle (Module) plugins and implementations are used to build
configurations that can be applied to all our application modules.

c) Develop an android application using radio button. 4M

Ans [Consider any relevant example of Radio Button and in XML file, consider XML Code 2 M,
minimum attributes] Java Code 2 M

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools=http://schemas.android.com/tools

Page No: 16 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="30dp"
tools:context=".frame">

<TextView android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Radio Button"
android:textSize="20dp"
android:gravity="center"
android:textColor="#f00"/>

<RadioGroup android:id="@+id/group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text1">

<RadioButton android:id="@+id/male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"/>

<RadioButton
android:id="@+id/female"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/male"
android:text="Female"/>
</RadioGroup>

<Button android:id="@+id/submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/group"
android:layout_marginTop="99dp"
android:layout_centerHorizontal="true"
android:text="Submit" />

</RelativeLayout>

Java File:
package com.example.ifcdiv;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

Page No: 17 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.widget.RadioButton;

import android.widget.Toast;

public class frame extends AppCompatActivity

RadioButton male,female;

Button b1;

@Override

protected void onCreate(Bundle savedInstanceState)

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_frame);

male=findViewById(R.id.male);

female=findViewById(R.id.female);

b1=findViewById(R.id.submit);

b1.setOnClickListener(new View.OnClickListener()

@Override

public void onClick(View v)

String selected; if(male.isChecked())


{
selected="You selected"+male.getText();
}
else
{
selected="You Selected"+female.getText();
}
Toast.makeText(getApplicationContext(),selected,Toast.LENGTH_LONG).show();
} });
}
}

Page No: 18 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
d) Develop an application to send and receive SMS. (Write only Java and 4M
permission tag in manifest file)

An Permissions and <receiver> tag required in AndroidManifest.xml (Permission 2 M,


s Java Code 2 M)
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.WRITE_SMS"/>
<receiver
android:name=".SmsReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>

MainActivity.java
(Cosidering appropriate layout file with 2 edit text boxes namely for phone
number,
message and a button for sending sms)
package com.example.testreceivesms;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;

Page No: 19 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
SmsReceiver sms= new SmsReceiver();
EditText et1,et2;
Button b1;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1=findViewById(R.id.etPhno);
et2=findViewById(R.id.etmsg);
b1=findViewById(R.id.btnSms);

if(ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.SEND_SMS)!=

PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(MainActivity.this,new
String[]{Manifest.permission.SEND_SMS},100);
}
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
String phno= et1.getText().toString();
String msg=et2.getText().toString();
SmsManager smsManager= SmsManager.getDefault();
smsManager.sendTextMessage(phno,null,msg,null,null);

Page No: 20 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Toast.makeText(MainActivity.this,"Sms sent successfully",
Toast.LENGTH_LONG).show();
}
catch(Exception e)
{
Toast.makeText(MainActivity.this,"Sms failed to send... try again",
Toast.LENGTH_LONG).show();
}
}

});

}
@Override
protected void onStart() {
super.onStart();
IntentFilter filter=new
IntentFilter("android.provider.Telephony.SMS_RECEIVED");
registerReceiver(sms,filter);
}
@Override
protected void onStop() {
super.onStop();
unregisterReceiver(sms);
}
}

SmsReceiver.java
package com.example.testreceivesms;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

Page No: 21 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.widget.Toast;
public class SmsReceiver extends BroadcastReceiver {
SmsReceiver(){}
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
// Retrieve the SMS Messages received
Object[] sms = (Object[]) bundle.get("pdus");
// For every SMS message received
for (int i=0; i < sms.length; i++) {
// Convert Object array
SmsMessage smsMessage = SmsMessage.createFromPdu((byte[]) sms[i]);
String phone = smsMessage.getOriginatingAddress();
String message = smsMessage.getMessageBody().toString();
Toast.makeText(context, “Received from “+ phone + ": " + message,
Toast.LENGTH_SHORT).show();
}
}
}
}

e) Draw and explain activity life cycle. 4M


Ans Activities have a predefined life-cycle methods as follows: Diagram 2 M,
Explanation 2 M

Page No: 22 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

onCreate (): Called then the activity is created. Used to initialize the activity, for
example create the user interface.
onStart ():called when activity is becoming visible to the user.
onResume (): Called if the activity get visible again and the user starts interacting
with the activity again. Used to initialize fields, register listeners, bind
to services, etc.
onPause (): Called once another activity gets into the foreground. Always called
before the activity is not visible anymore. Used to release resources or save
application data. For example you unregister listeners, intent receivers, unbind from
services or remove system service listeners.
onStop (): Called once the activity is no longer visible. Time or CPU intensive
shutdown operations, such as writing information to a database should be down in
the onStop() method. This method is guaranteed to be called as of API 11.
onDestroy (): called before the activity is destroyed.

Page No: 23 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

5. Attempt any TWO of the following: 12 M

a) Develop a program to perform addition, subtraction, division, 6M


multiplication of two numbers and display the result. (Use appropriate
UI controls).

Ans Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and Any appropriate UI
fill all required details to create a new project. controls and layout
with correct
Step 2 − Add the following code to res/layout/activity_main.xml. activity_main.xml
file-3 M
<?xml version="1.0" encoding="utf-8"?>
MainActivity.java
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
file-3 M
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dp">
<TextView
android:id="@+id/textResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="70dp"
android:background="#008080"
android:padding="5dp"
android:text="Code4Example"
android:textColor="#fff"
android:textSize="24sp"
android:textStyle="bold" />
<EditText
android:id="@+id/editNum1"
android:inputType="number"
android:layout_width="match_parent"

Page No: 24 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<EditText
android:id="@+id/editNum2"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/editNum1"
android:layout_centerInParent="true" />
<GridLayout
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_below="@+id/editNum2"
android:columnCount="2"
android:rowCount="2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="1dp"
android:onClick="btnAdd"
android:text="+" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"

Page No: 25 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_margin="1dp"
android:onClick="btnSub"
android:text="-" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="1dp"
android:onClick="btnMul"
android:text="*" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="1dp"
android:onClick="btnDiv"
android:text="/" />
</GridLayout>
</RelativeLayout>

Step 3 − Add the following code to src/MainActivity.java


import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
EditText editNum1,editNum2;
TextView textResult;

Page No: 26 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

editNum1= findViewById(R.id.editNum1);
editNum2= findViewById(R.id.editNum2);
textResult= findViewById(R.id.textResult);
}
public void btnAdd(View view){
double num1 = Double.parseDouble(editNum1.getText().toString());
double num2 = Double.parseDouble(editNum2.getText().toString());
double result = num1 + num2;
textResult.setText(Double.toString(result));
}
public void btnSub(View view){
double num1 = Double.parseDouble(editNum1.getText().toString());
double num2 = Double.parseDouble(editNum2.getText().toString());
double result = num1 - num2;
textResult.setText(Double.toString(result));
}
public void btnMul(View view){
double num1 = Double.parseDouble(editNum1.getText().toString());
double num2 = Double.parseDouble(editNum2.getText().toString());
double result = num1 * num2;
textResult.setText(Double.toString(result));
}
public void btnDiv(View view){

Page No: 27 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
double num1 = Double.parseDouble(editNum1.getText().toString());
double num2 = Double.parseDouble(editNum2.getText().toString());
double result = num1 / num2;
textResult.setText(Double.toString(result));
}
}
Output:

b) Develop an application to display a Google Map. (Write JAVA & 6M


Manifest file)

An AndroidManifest.xml code: correct Android


Manifest.xml file-3
Page No: 28 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
s <?xml version="1.0" encoding="utf-8"?> M
<manifest xmlns:android="http://schemas.android.com/apk/res/android" MapsActivity.java
package="example.com.mapexample"> file-3 M
<!--
The ACCESS_COARSE/FINE_LOCATION permissions are not requir
ed to use
Google Maps Android API v2, but you must specify either coarse or fine

location permissions for the 'MyLocation' functionality.


-->
<uses-
permission android:name="android.permission.ACCESS_FINE_LOCATION
" />
<uses-
permission android:name="android.permission.ACCESS_COARSE_LOCAT
ION" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
 android:theme="@style/AppTheme">

 <meta-data
 android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />

 <activity
 android:name=".MapsActivity"
 android:label="@string/title_activity_maps">
 <intent-filter>
 <action android:name="android.intent.action.MAIN" />

 <category android:name="android.intent.category.LAUNCHER" />
Page No: 29 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
 </intent-filter>
 </activity>
 </application>
 </manifest>
code of MapsActivity.java :

 package example.com.mapexample;

 import android.support.v4.app.FragmentActivity;
 import android.os.Bundle;
 import com.google.android.gms.maps.CameraUpdateFactory;
 import com.google.android.gms.maps.GoogleMap;
 import com.google.android.gms.maps.OnMapReadyCallback;
 import com.google.android.gms.maps.SupportMapFragment;
 import com.google.android.gms.maps.model.LatLng;
 import com.google.android.gms.maps.model.MarkerOptions;

public class MapsActivity extends FragmentActivity implements OnMapReadyC
allback{
 private GoogleMap mMap;

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

// Obtain the SupportMapFragment and get notified when the map is ready to be used
.

SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragment


Manager()
 .findFragmentById(R.id.map);
 mapFragment.getMapAsync(this);
 }
 @Override
 public void onMapReady(GoogleMap googleMap) {

Page No: 30 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
 mMap = googleMap;
 // Add a marker in Sydney and move the camera
 LatLng sydney = new LatLng(-34, 151);
 mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sy
dney"));
 mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
 }
 }

c) Develop an application to convert thanks" text to speech as given in the 6M


following GUI.

Ans Code of activity_main.xml activity_main.xml


file- 2M
<?xml version="1.0" encoding="utf-8"?>
toolbar_title_layout.
<RelativeLayout xml file-1 M
xmlns:android="http://schemas.android.com/apk/res/android"
MainActivity.java
xmlns:tools="http://schemas.android.com/tools" file-3 M
android:layout_width="match_parent"

android:layout_height="match_parent" (Any other correct


android:paddingLeft="@dimen/activity_horizontal_margin" logic can be
considered)
android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

Page No: 31 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:paddingBottom="@dimen/activity_vertical_margin"

tools:context=".MainActivity"

android:transitionGroup="true">

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Android Text to Speech(TTS) Demo"

android:id="@+id/textView"

android:layout_below="@+id/textview"

android:layout_centerHorizontal="true"

android:textColor="#ff7aff24"

android:textSize="35dp" />

<EditText

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/editText"

android:layout_below="@+id/textView"

android:layout_marginTop="46dp"

android:text="thanks"

android:layout_alignParentRight="true"

android:layout_alignParentEnd="true"

android:layout_alignParentLeft="true"

android:layout_alignParentStart="true"

android:textColor="#ff7aff10"

android:textColorHint="#ffff23d1" />

<Button

android:layout_width="wrap_content"

Page No: 32 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"

android:text="CLICK TO CONVERT TEXT TO SPEECH"

android:id="@+id/button"

android:layout_below="@+id/editText"

android:layout_centerHorizontal="true"

android:layout_marginTop="46dp"

android:textSize="15dp" />

</RelativeLayout>

Code of toolbar_title_layout.xml file

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_height="wrap_content"

android:orientation="vertical"

android:gravity="center"

<TextView

android:padding="4dp"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="TextToSpeechDemo"

android:gravity="center"

android:textSize="16sp"

android:textStyle="bold"

android:textColor="@android:color/white"/>

</LinearLayout>

Page No: 33 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Code of MainActivity.java.

package com.example.texttospeech.myapplication;

import android.app.Activity;

import android.os.Bundle;

import android.speech.tts.TextToSpeech;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import java.util.Locale;

import android.widget.Toast;

public class MainActivity extends Activity {

TextToSpeech t1;

EditText ed1;

Button b1;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CU
STOM);

getSupportActionBar().setCustomView(R.layout.toolbar_title_layout);

setContentView(R.layout.activity_main);

ed1=(EditText)findViewById(R.id.editText);

b1=(Button)findViewById(R.id.button);

t1=new TextToSpeech(getApplicationContext(), new


TextToSpeech.OnInitListener() {

@Override

public void onInit(int status) {

Page No: 34 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
if(status != TextToSpeech.ERROR) {

t1.setLanguage(Locale.UK);

});

b1.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

String toSpeak = ed1.getText().toString();

Toast.makeText(getApplicationContext(),
toSpeak,Toast.LENGTH_SHORT).show();

t1.speak(toSpeak, TextToSpeech.QUEUE_FLUSH, null);

});

public void onPause(){

if(t1 !=null){

t1.stop();

t1.shutdown();

super.onPause();

6. Attempt any TWO of the following: 12 M

a) Develop an application to update a record of an employee whose emp.id is 6M


‘E101’ in SQlite database. Change employee name from “POR" to
“XYZ". Also display the updated record (Write .java and .xml files).

Page No: 35 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans activity_update_emp.xml file activity_update
_emp.xmlfile-1 M
<?xml version="1.0" encoding="utf-8"?>
DBHandler.java
<LinearLayout file-2 M
xmlns:android="http://schemas.android.com/apk/res/android" empRVAdapter.java
file-1 M
xmlns:tools="http://schemas.android.com/tools"
Update java file- 2
android:layout_width="match_parent"
M
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<!--Edit text to enter employee name-->
<EditText
android:id="@+id/idEdtEmpName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:hint="Enter Employee Name" />
<!--edit text for employee salary-->
<EditText
android:id="@+id/idEdtEmpSalary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:hint="Enter Employee Salary" />

<!--button for adding new employee-->


<Button
android:id="@+id/idBtnAddCourse"
android:layout_width="match_parent"

Page No: 36 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="Add Employee"
android:textAllCaps="false" />
</LinearLayout>

DBHandler.java file
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DBHandler extends SQLiteOpenHelper {
// creating a constant variables for our database.
// below variable is for our database name.
private static final String DB_NAME = "empdb";

// below int is our database version


private static final int DB_VERSION = 1;

// below variable is for our table name.


private static final String TABLE_NAME = "myemp";

// below variable is for our id column.


private static final String ID_COL = "id";

// below variable is for our course name column


private static final String NAME_COL = "emp_name";

Page No: 37 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
// below variable is for our employee salary column.
private static final String TRACKS_COL = "emp_salary";

// creating a constructor for our database handler.


public DBHandler(Context context) {
super(context, DB_NAME, null, DB_VERSION);
}
// below method is for creating a database by running a sqlite query
@Override
public void onCreate(SQLiteDatabase db) {
// on below line we are creating
// an sqlite query and we are
// setting our column names
// along with their data types.
String query = "CREATE TABLE " + TABLE_NAME + " ("
+ ID_COL + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ NAME_COL + " TEXT,"
+ SALARY_COL + " TEXT)";

// at last we are calling a exec sql


// method to execute above sql query
db.execSQL(query);
}

// this method is use to add new EMPLOYEE to our sqlite database.


public void addNewCourse(String empName, String empSalary) {

// on below line we are creating a variable for

Page No: 38 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
// our sqlite database and calling writable method
// as we are writing data in our database.
SQLiteDatabase db = this.getWritableDatabase();
// on below line we are creating a
// variable for content values.
ContentValues values = new ContentValues();

// on below line we are passing all values


// along with its key and value pair.
values.put(NAME_COL, empName);
values.put(TRACKS_COL, empSalary);

// after adding all values we are passing


// content values to our table.
db.insert(TABLE_NAME, null, values);

// at last we are closing our


// database after adding database.
db.close();
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// this method is called to check if the table exists already.
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
}

Page No: 39 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
empRVAdapter.java file
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
// creating variables for our edittext, button and dbhandler
private EditText empNameEdt, empSalaryEdt;
private Button addempBtn;
private DBHandler dbHandler;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// initializing all our variables.
empNameEdt = findViewById(R.id.idEdtempName);
empSalaryEdt = findViewById(R.id.idEdtempSalary);
addempBtn = findViewById(R.id.idBtnAddemp);
// creating a new dbhandler class
// and passing our context to it.
dbHandler = new DBHandler(MainActivity.this);

// below line is to add on click listener for our add emp button.
addCourseBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

Page No: 40 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
// below line is to get data from all edit text fields.
String empName = empNameEdt.getText().toString();
String empSalary = empSalaryEdt.getText().toString();
// validating if the text fields are empty or not.
if (empName.isEmpty() && empSalary.isEmpty() &&) {
Toast.makeText(MainActivity.this, "Please enter all the data..",
Toast.LENGTH_SHORT).show();
return;
}
// on below line we are calling a method to add new
// employee to sqlite data and pass all our values to it.
dbHandler.addNewemp(empName, empSalary);

// after adding the data we are displaying a toast message.


Toast.makeText(MainActivity.this, "Employee has been added.",
Toast.LENGTH_SHORT).show();
empNameEdt.setText("");
empSalaryEdt.setText("");
}
});
}
}

Update employee record java file:


import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

Page No: 41 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import androidx.appcompat.app.AppCompatActivity;
public class UpdateCourseActivity extends AppCompatActivity {
// variables for our edit text, button, strings and dbhandler class.
private EditText empNameEdt, empSalaryEdt;
private Button updateempBtn;
private DBHandler dbHandler;
String empName, empSalary;

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

// initializing all our variables.


empNameEdt = findViewById(R.id.idEdtempName);
empSalaryEdt = findViewById(R.id.idEdtempSalary);
updateempBtn = findViewById(R.id.idBtnUpdateemp);

// on below line we are initializing our dbhandler class.


dbHandler = new DBHandler(UpdateempActivity.this);

// on below lines we are getting data which


// we passed in our adapter class.
empName = getIntent().getStringExtra("emp_name");
empSalary = getIntent().getStringExtra("emp_salary");
// setting data to edit text
// of our update activity.
empNameEdt.setText(empName);

Page No: 42 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
empSalaryEdt.setText(empSalary);

// adding on click listener to our update course button.


updateempBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

// inside this method we are calling an update employee


// method and passing all our edit text values.
dbHandler.updateemp(empName, empNameEdt.getText().toString(),
empSalaryEdt.getText().toString());

// displaying a toast message that our employee database has been updated.
Toast.makeText(UpdateempActivity.this, "Employee Record Updated..",
Toast.LENGTH_SHORT).show();

// launching our main activity.


Intent i = new Intent(UpdateempActivity.this, MainActivity.class);
startActivity(i);
}
});
}
}

b) i) Describe all steps in application deployment on google playstore. 6M

ii) Write steps for customized permissions.


Ans Application
a) Application deployment steps: deployment steps:3
M
Publishing is the general process that makes your Android app available to users.
When you publish an Android app on google play store, you do the following: Steps for
Customized
 Prepare the app for release. Permissions:3 M

Page No: 43 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
During the preparation step, you build a release version of your app.
 Release the app to users.
During the release step, you publicize, sell, and distribute the release version
of your app, which users can download and install on their Android-powered
devices.

Prepare your app for release

1)Preparing your app for release is a multistep process involving the following tasks:

 Configure your app for release.


At a minimum, you need to make sure that logging is disabled and removed
and that your release variant has debuggable false for Groovy
or isDebuggable = false for Kotlin script set. You should also set your app's
version information.
 Build and sign a release version of your app.
You can use the Gradle build files with the release build type to build and
sign a release version of your app. For more information, see Build and run
your app.
 Test the release version of your app.
Before you distribute your app, you should thoroughly test the release version
on at least one target handset device and one target tablet device. Firebase
Test Lab is useful for testing across a variety of devices and configurations.
 Update app resources for release.
Make sure that all app resources, such as multimedia files and graphics, are
updated and included with your app or staged on the proper production
servers.
 Prepare remote servers and services that your app depends on.
If your app depends on external servers or services, make sure they are secure
and production ready.

2) Signing of Application
 Application signing allows developers to identify the author of the
application and to update their application without creating complicated
interfaces and permissions.
 Every application that is run on the Android platform must be signed by the
developer.

Page No: 44 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

 Applications that attempt to install without being signed will be rejected by


either Google Play or the package installer on the Android device.

APK Signing Schemes


 v1 Scheme: based on JAR signing.
 v2 Scheme: APK Signature Scheme v2, which was introduced in Android
7.0.
 v3 Scheme: APK Signature Scheme v3, which was introduced in Android 9.

b) Steps for Customized Permissions:

1)App signing

All APKs must be signed with a certificate whose private key is held by their
developer. The certificate does not need to be signed by a certificate authority. It's
allowable, and typical, for Android apps to use self-signed certificates. The purpose
of certificates in Android is to distinguish app authors. This lets the system grant or
deny apps access to signature-level permissions and grant or deny an app's request to
be given the same Linux identity as another app.

2)Grant signature permissions after device manufacturing time

Starting in Android 12 (API level 31), the knownCerts attribute for signature-level
permissions lets you refer to the digests of known signing certificates at declaration
time.

You can declare the knownCerts attribute and use the knownSigner flag in your
app's protectionLevel attribute for a particular signature-level permission. Then, the
system grants that permission to a requesting app if any signer in the requesting app's
signing lineage, including the current signer, matches one of the digests that's
declared with the permission in the knownCerts attribute.

The knownSigner flag lets devices and apps grant signature permissions to other
apps without having to sign the apps at the time of device manufacturing and
shipment.

3)User IDs and file access

At install time, Android gives each package a distinct Linux user ID. The identity
remains constant for the duration of the package's life on that device. On a different
device, the same package might have a different UID—what matters is that each
package has a distinct UID on a given device.

Because security enforcement happens at the process level, the code of any two
Page No: 45 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
packages can't normally run in the same process, since they need to run as different
Linux users.

Any data stored by an app is assigned that app's user ID and isn't normally accessible
to other packages.

For example, an app that needs to control which other apps can start one of its
activities can declare a permission for this operation as follows:

<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp" >

<permission
android:name="com.example.myapp.permission.DEADLY_ACTIVITY"
android:label="@string/permlab_deadlyActivity"
android:description="@string/permdesc_deadlyActivity"
android:permissionGroup="android.permission-group.COST_MONEY"
android:protectionLevel="dangerous" />
...
</manifest>
c) Develop a program to TURN ON and OFF bluetooth. 6M
Write .java file and permission tags.
Ans Code of MainActivity.java AndroidManifest.x
ml file-3 M
package com.example.bluetooth.myapplication;
MainActivity.java
import android.app.Activity; file-3 M
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

import android.widget.Toast;
import java.util.ArrayList;
import java.util.Set;

public class MainActivity extends Activity {


Button b1,b2,b3,b4;
private BluetoothAdapter BA;
private Set<BluetoothDevice>pairedDevices;
ListView lv;

Page No: 46 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

b1 = (Button) findViewById(R.id.button);
b2=(Button)findViewById(R.id.button2);
b3=(Button)findViewById(R.id.button3);
b4=(Button)findViewById(R.id.button4);

BA = BluetoothAdapter.getDefaultAdapter();
lv = (ListView)findViewById(R.id.listView);
}

public void on(View v){


if (!BA.isEnabled()) {
Intent turnOn = new
Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(turnOn, 0);
Toast.makeText(getApplicationContext(), "Turned
on",Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "Already on",
Toast.LENGTH_LONG).show();
}
}

public void off(View v){


BA.disable();
Toast.makeText(getApplicationContext(), "Turned off"
,Toast.LENGTH_LONG).show();
}

public void visible(View v){


Intent getVisible = new
Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
startActivityForResult(getVisible, 0);
}

public void list(View v){


pairedDevices = BA.getBondedDevices();

ArrayList list = new ArrayList();

for(BluetoothDevice bt : pairedDevices) list.add(bt.getName());


Toast.makeText(getApplicationContext(), "Showing Paired
Devices",Toast.LENGTH_SHORT).show();

Page No: 47 | 48

Downloaded by Nitesh Poojari ([email protected])


lOMoARcPSD|46833019

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION


(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
final ArrayAdapter adapter = new
ArrayAdapter(this,android.R.layout.simple_list_item_1, list);

lv.setAdapter(adapter);
}
}
Permission Tags
AndroidManifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.bluetooth.myapplication" >
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<activity
android:name=".MainActivity"
android:label="@string/app_name" >

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

</activity>

</application>
</manifest>

Page No: 48 | 48

Downloaded by Nitesh Poojari ([email protected])


MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER – 2024 EXAMINATION
Model Answer – Only for the Use of RAC Assessors

Subject Name: Mobile Application Development Subject Code: 22617


Important Instructions to examiners: XXXXX
1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not applicable for
subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The figures
drawn by candidate and model answer may vary. The examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may vary and
there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based on
candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual (English +
Marathi) medium is introduced at first year of AICTE diploma Programme from academic year 2021-2022. Hence if
the students in first year (first and second semesters) write answers in Marathi or bilingual language (English
+Marathi), the Examiner shall consider the same and assess the answer based on matching of concepts with model
answer.

Q. Sub Answer Marking


No. Q. Scheme
N.

1 Attempt any FIVE of the following: 10 M

a) Explain the android ecosystem. 2M

Ans Explanation 2 M

• Ecosystem in Market terminology refers to the inter-dependence between


demand and supply.

• In the Android ecosystem this translates to inter-dependence between users,


developers, and equipment makers. One cannot exist without the other:

• Google develops android

Page No: 1 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• Users buy devices and applications

• Original Equipment makers sell devices, sometimes bundled with


applications

• Developers buy devices, then make and sell applications

• Freelance Android Developer developers have the skills to contribute to the


ecosystem for android development, they are who creates their own
applications and published them on googles play store.

b) Define Emulator. 2M

Ans An Android emulator is a tool that creates virtual Android devices on your computer. Correct
The emulator lets you prototype, develop and test Android applications without using Definition 2 M
a physical device

c) Name two classes used to play audio and video in Android. 2M

Ans 1) Media Player Any two class


2) Media Controller names 1 M each
3) Audio Manager
d) List any four folders from directory structure of Android project 2M
and elaborate in one line.

Ans Folders from directory structure: List of names of


any four folders:
1)app: The App folder contains three subfolders (manifests, java and res) that make up 1 M and
our application. They are divided so that it should be fairly easy to determine which elaboration in
resources go in which folder. one line: 1 M
2)Manifest: This is where we would put our manifest files. Most Android apps have
single manifest file. But an app may have several manifest files due to application
versioning, or for supporting specific hardware.
3)Java: This is the folder in our project where we will be storing all of the source code
files written in Java programming language.
4)res: It contains folders that help us to separate and sort the resources of our
application.
Resources basically mean all the needed files except the source code.
5)drawable: The drawable folder contains graphics that can be drawn to the screen.
6)layout: The layout folder contains XML files used for your layouts. These file are
used
to set up the layout for your Activity and is used for basic alignment of your layouts,
components, widgets, and similar resources that are used for the UI of your
application.
7)mipmap : The mipmap folder contains the launcher icon files for the app. A launcher
icon is a graphic that represents your app to users.
8)values: The values folder contains XML files that contain simple values, such as
Page No: 2 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
strings, integers, and colors. The values folder is used to keep track of the values we
will be using in our application.

e) List types of permissions in android. 2M

Ans 1. Normal Permissions Any two, 1 M


2. Dangerous Permissions for each
3. Signature Permissions
f) List attributes of radio button. (Any Four) 2M

Ans • id Any four: ½ M


• text for each
• textcolor
• textsize
• checked
• layout_width
• layout_height
• gravity

g) Describe the process of getting the map API key. 2M

Ans Step 1: Create a Google Cloud Project Correct steps 2


M
Step 2: Enable the Maps SDK for Android

Step 3: Get the API Key

Step 4: Get Your SHA-1 Fingerprint (for Android Apps)

Step 5: Add the API Key to Your Android Project

Step 6: Verify and Test the API Key

2. Attempt any THREE of the following: 12 M

a) Describe Android Architecture with diagram. 4M

Ans 1. Applications: Explanation for


Android
• The top layer of android architecture is Applications. The native and third- Architecture=2M
party applications like Contacts, Email, Music, Gallery, Clock, Games, etc. and
whatever we will build those will be installed on this layer only. Diagram=2M

• The application layer runs within the Android run time using the classes and
services made available from the application framework.

Page No: 3 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Fig: Android Architecture

2. Application Framework:

• The Application Framework provides the classes used to create an Android


application. It also provides a generic abstraction for hardware access and
manages the user interface and application resources.

• It basically provides the services through which we can create the particular
class and make that class helpful for the Applications creation.

• The application framework includes services like telephony service, location


services, and notification. manager, NFC service, view system, etc. which we
can use for application development as per our requirements.
3. Android Runtime:

• Android Runtime environment is an important part of Android rather than an

Page No: 4 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
internal part and it contains a components like core libraries and the Dalvik
virtual machine.

• The Android run time is the engine that powers our applications along with the
libraries and it forms the basis for the application framework.

• Dalvik Virtual Machine (DVM) is a register-based virtual machine like Java


Virtual Machine (JVM).

• It is specially designed and optimized for android to ensure that a device can
run multiple instances efficiently. It relies on the Linux kernel for threading
and low-level memory

• management.
• The core libraries in android runtime will enable us to implement an android
applications using standard JAVA programming language.

4. Platform Libraries:

• The Platform Libraries includes various C/C++ core libraries and Java based
libraries such as SSL,libc, Graphics, SQLite, Webkit, Media, Surface Manger,
OpenGL etc. to provide a support for android development.

5. Linux Kernel:

• Linux Kernel is a bottom layer and heart of the android architecture. It is heart
of Android architecture that exists at the root of android architecture and
contains all the low-level device drivers for the various hardware components
of an Android device.

• Linux Kernel is responsible fro device drivers, power management, memory


management, device management and resource access. It manage all the
drivers such as display drivers, camera drivers, Bluetooth drivers, audio
drivers, memory drivers, etc. which are mainly required for the android device
during the runtime.

• The Linux Kernel will provide an abstraction layer between the device
hardware and the remainder of the stack. It is responsible for memory
management, power management, device management, resource access, etc.

b) Explain relative layout with suitable example. 4M

Ans A RelativeLayout is a type of ViewGroup that allows you to position its child views Explanation 2
relative to each other or to the parent container. This layout is powerful because it lets M,
you align views based on rules such as being above, below, to the left, to the right, or Example 2 M
(Consider any
centered relative to other views or the parent layout.
suitable
example)

Page No: 5 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Attributes Used in RelativeLayout:

• android:layout_alignParentTop: Aligns the view to the top of the parent.

• android:layout_alignParentLeft or android:layout_alignParentStart:
Aligns the view to the left or start of the parent.

• android:layout_alignParentRight or android:layout_alignParentEnd:
Aligns the view to the right or end of the parent.

• android:layout_below: Places the view below another view.

• android:layout_above: Places the view above another view.


• android:layout_toLeftOf or android:layout_toStartOf: Places the view to
the left or start of another view.
• android:layout_toRightOf or android:layout_toEndOf: Places the view to
the right or end of another view.

• android:centerHorizontal: Centers the view horizontally.


• android:centerVertical: Centers the view vertically.

• android:layout_centerInParent: Centers the view both horizontally and


vertically within the parent layout.

Example of RelativeLayout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"

android:layout_height="match_parent">

<TextView

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Hello, RelativeLayout!"

android:textSize="20sp"

android:layout_alignParentTop="true"

android:layout_centerHorizontal="true"/>

<Button

Page No: 6 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:id="@+id/button1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Click Me"

android:layout_below="@id/textView1"

android:layout_centerHorizontal="true"/>

<ImageView

android:id="@+id/imageView1"

android:layout_width="100dp"

android:layout_height="100dp"

android:src="@drawable/ic_launcher_foreground"

android:layout_below="@id/button1"

android:layout_centerHorizontal="true"/>

</RelativeLayout>

c) Design a student registration form. 4M

Ans <?xml version="1.0" encoding="utf-8"?> Any Correct


Logic of XML
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" code: 4 M

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:padding="16dp">

<TextView

android:id="@+id/formTitle"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

Page No: 7 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:text="Student Registration Form"

android:textSize="24sp"

android:textColor="#000000"

android:layout_gravity="center"

android:layout_marginBottom="20dp"/>

<TextView

android:id="@+id/labelName"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Full Name:"

android:textSize="16sp"

android:layout_marginBottom="8dp"/>

<EditText

android:id="@+id/etName"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Enter Full Name"

android:inputType="textPersonName"

android:layout_marginBottom="16dp"/>

<TextView

android:id="@+id/labelEmail"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Email Address:"

Page No: 8 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:textSize="16sp"

android:layout_marginBottom="8dp"/>

<EditText

android:id="@+id/etEmail"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Enter Email"

android:inputType="textEmailAddress"

android:layout_marginBottom="16dp"/>

<TextView

android:id="@+id/labelGender"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Gender:"

android:textSize="16sp"

android:layout_marginBottom="8dp"/>

<RadioGroup

android:id="@+id/radioGroupGender"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal"

android:layout_marginBottom="16dp">

Page No: 9 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<RadioButton

android:id="@+id/rbMale"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Male"

android:layout_marginEnd="16dp"/>

<RadioButton

android:id="@+id/rbFemale"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Female"

android:layout_marginEnd="16dp"/>

<RadioButton

android:id="@+id/rbOther"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Other"/>

</RadioGroup>

<TextView

android:id="@+id/labelCourse"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Select Course:"

Page No: 10 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:textSize="16sp"

android:layout_marginBottom="8dp"/>

<Spinner

android:id="@+id/spinnerCourse"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginBottom="16dp" />

<Button

android:id="@+id/btnSubmit"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Submit"

android:textSize="18sp"

android:layout_marginTop="16dp" />

</LinearLayout>

d) Describe the steps for publishing android app. 4M

Ans Step 1: Create a Developer Account Correct Steps 4


M
• Before you can publish any app on Google Play, you need to create a
Developer Account. You can easily sign up for one using your existing Google
Account.

• You’ll need to pay a one-time registration fee of $25 using your international
credit or debit card. It can take up to 48 hours for your registration to be fully
processed.
Step 2: Plan to Sell? Link Your Merchant Account

• If you want to publish a paid app or plan to sell in-app purchases, you need to

Page No: 11 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
create a payments center profile, i.e. a merchant account.

• A merchant account will let you manage your app sales and monthly payouts,
as well as analyze your sales reports right in your Play Console.

Step 3: Create an App

• Now you have create an application by clicking on 'Create Application'. Here


you have to select your app’s default language from the drop-down menu and
then type in a title for your app. The title of your app will show on Google Play
after you’ve published.

Step 4: Prepare Store Listing

• Before you can publish your app, you need to prepare its store listing. These
are all the details that will show up to customers on your app’s listing on
Google Play. You not necessarily complete it at once , you can always save a
draft and revisit it later when you’re ready to publish.

• The information required for your store listing is divided into several
categories such as Product Details containing title, short and full description of
the app, Your app’s title and description should be written with a great user
experience in mind. Use the right keywords, but don’t overdo it. Make sure
your app doesn’t come across as spam-y or promotional, or it will risk getting
suspended on the Play Store.

• Graphic Assets where you can add screenshots, images, videos, promotional
graphics, and icons that showcase your app’s features and functionality.

• Languages & Translations, Categorization where in category can be selected to


which your app belong to. Contact Details , Privacy Policy for apps that
request access to sensitive user data or permissions, you need to enter a
comprehensive privacy policy that effectively discloses how your app collects,
uses, and shares that data.
Step 5: Upload APK to an App Release

• Finally upload your app, by uploading APK file. Before you upload APK, you
need to create an app release. You need to select the type of release you want
to upload your first app version to.

• You can choose between an internal test, a closed test, an open test, and a
production release. The first three releases allow you to test out your app
among a select group of users before you make it go live for everyone to
access.
• This is a safer option because you can analyze the test results and optimize or

Page No: 12 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
fix your app accordingly if you need to before rolling it out to all users.

• Once you create a production release, your uploaded app version will become
accessible to everyone in the countries you choose to distribute it in and click
on ‘Create release.’

Step 6: Provide an Appropriate Content Rating

• If you don’t assign a rating to your app, it will be listed as ‘Unrated’. Apps that
are ‘Unrated’ may get removed from Google Play.

• To rate your app, you need to fill out a content rating questionnaire An
appropriate content rating will also help you get to the right audience, which
will eventually improve your engagement rates.

Step 7: Set Up Pricing & Distribution

• Before you can fill out the details required in this step, you need to determine
your app’s monetization strategy. Once you know how your app is going to
make money, you can go ahead and set up your app as free or paid.

• You can always change your app from paid to free later, but you cannot change
a free app to paid. For that, you’ll need to create a new app and set its price.

Step 8: Rollout Release to Publish Your App

• The final step involves reviewing and rolling out your release after making sure
you’ve taken care of everything else.

• Before you review and rollout your release, make sure the store listing, content
rating, and pricing and distribution sections of your app each have a green
check mark next to them.
• Once you’re sure about the correctness of the details, select your app and
navigate to ‘Release management’ – ‘App releases.’

• You can always opt for reviews by clicking on ‘Review’ to be taken to the
‘Review and rollout release’ screen. Here, you can see if there are any issues or
warnings you might have missed out on.

• Finally, select ‘Confirm rollout.’ This will also publish your app to all users in
your target countries on Google Play.

3. Attempt any THREE of the following: 12 M

a) Difference between JVM and DVM any four point. 4M

Page No: 13 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans 4 correct points-
4M
DVM JVM
It is Register based which is designed to It is Stack based.
run on low memory.
DVM uses its own byte code and runs JVM uses java byte code and runs
the “.Dex” file. From Android 2.2 SDK “.class” file having JIT (Just In Time).
Dalvik has got a Just in Time compiler
DVM has been designed so that a device A single instance of JVM is shared with
can run multiple instances of the VM multiple applications.
efficiently. Applications are given their
own instance
DVM supports the Android operating JVM supports multiple operating
system only. systems.
There is a constant pool for every It has a constant pool for every class.
application.
Here the executable is APK. Here the executable is JAR
b) Describe sensors use in Android. 4M

Ans Most of the android devices have built-in sensors that measure motion, orientation, and 1 M for each
various environmental condition. The android platform supports three broad categories sensor’s use
of sensors.
1. Motion Sensors
These are used to measure acceleration forces and rotational forces along with three
axes.
2. Environmental sensors
These are used to measure the environmental changes such as temperature, humidity
etc.
3. Position sensors
These are used to measure the physical position of device.
Example:
TYPE_ACCELE_ROMETER
TYPE_GRAVITY
TYPE_LIGHT
TYPE_ORIENTATION
TYPE_PRESSURE
Some of the sensors are hardware based and some are software based sensors.
Whatever the sensor is, android allows us to get the raw data from these sensors and
use it in our application.

Page No: 14 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Android provides SensorManager and Sensor classes to use the sensors in our
application.
1) SensorManager class
The android.hardware.SensorManager class provides methods :
o to get sensor instance,
o to access and list sensors,
o to register and unregister sensor listeners etc.
You can get the instance of SensorManager by calling the method getSystemService()
and passing the SENSOR_SERVICE constant in it.
SensorManager sm = (SensorManager)getSystemService(SENSOR_SERVICE);
2) Sensor class
The android.hardware.Sensor class provides methods to get information of the sensor
such as sensor name, sensor type, sensor resolution, sensor type etc.
3) SensorEvent class
Its instance is created by the system. It provides information about the sensor.
4) SensorEventListener interface
It provides two call back methods to get information when sensor values (x,y and z)
change or sensor accuracy changes.

c) Develop a program to implement - List View of 6 item. 4M

Ans 1. XML Layout (res/layout/activity_main.xml) 2 M for xml,


2 M for Java
<?xml version="1.0" encoding="utf-8"?> code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<ListView
android:id="@+id/listView"
android:layout_width="match_parent"

Page No: 15 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content" />
</LinearLayout>
2. Java Code (MainActivity.java)
package com.example.listviewdemo;
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);
ListView listView = findViewById(R.id.listView);

String[] items = {"Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(
this,
android.R.layout.simple_list_item_1,
items
);
listView.setAdapter(adapter);
}
}

d) Explain importance of developer console in android application development. 4M

Ans 1. Error Debugging: 1 M for each


importance
The console logs runtime errors, crashes, and warnings. It provides detailed stack
traces, making it easier to identify and fix issues during development.

Page No: 16 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
2. Real-Time Logs:
It displays real-time application logs, allowing developers to track events, actions, and
method calls while the app is running.
3. Performance Monitoring:
Helps measure memory usage, CPU activity, and network operations to optimize the
app’s performance.
4. Debugging UI Issues:
The console highlights UI-related errors like invalid layouts or missing resources,
helping ensure proper user interface design.
5. Testing and Feedback:
Supports testing by showing outputs of log messages (Log.d, Log.e, etc.), making it
easier to verify functionality and behavior during development.

4. Attempt any THREE of the following: 12 M

a) Write a steps to install android studio. 4M

Ans Pre-Installation Check List 1 M for each


1. Before installing Android SDK, there is need to install Java Development Kit correct step
(JDK). Ensure that JDK is at or above 1.8.
2. Uninstall older version(s) of "Android Studio" and "Android SDK", if any.

We need to install two packages:


1. Android Studio (IDE), which is an Integrated Development Environment (IDE)
2. Android SDK (Software Development Kit) for developing and running Android
apps.

Steps to install Android studio:


Download Android Studio
1. Click Download Android Studio. The Terms and Conditions page with the Android
Studio License Agreement opens.
2. Read the License Agreement.
3. At the bottom of the page, if you agree with the terms and conditions, select the I
have read and agree with the above terms and conditions checkbox.
4. Click Download Android Studio to start the download.
5. When prompted, save the file to a location where you can easily locate it, such as
the Downloads folder.
6. Wait for the download to complete.

Install Android Studio


a) Open the folder where you downloaded and saved the Android Studio
installation file.

Page No: 17 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
b) Double-click the downloaded file.
c) If you see a User Account Control dialog about allowing the installation to
make changes to your computer, click Yes to confirm the installation.
d) Click Next to start the installation.
e) Accept the default installation settings for all steps.
f) Click finish when installation is done.

Installing Android SDK


Within Android Studio, you can install the Android SDK as follows:
1. Click Tools > SDK Manager.
2. In the SDK Platforms tab, select Android Tiramisu Preview.
3. In the SDK Tools tab, select Android SDK Build.
4. Click OK to install the SDK.

b) List UI component explain any one with help of example. 4M

Ans • TextView 2 M for Listing ,

• EditText 2 M for
Example code
• Button XML or Java
Code
• ImageView

• ListView

• CheckBox

• RadioButton

• ProgressBar
Example Code:
XML Layout (activity_main.xml):
<Button
android:id="@+id/myButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me" />

Java Code (MainActivity.java):


package com.example.uicomponents;

Page No: 18 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button myButton = findViewById(R.id.myButton);
myButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(MainActivity.this, "Button Clicked!",
Toast.LENGTH_SHORT).show();
}
});
}
}
* Note: Consider any suitable example.

c) Develop a program for providing bluetooth connectivity. 4M

Ans 1. Add Permissions 3 M for program,


XML file 1 M for
permission
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns: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="40dp"
android:orientation="horizontal"

Page No: 19 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Bluetooth"
android:id="@+id/text"
android:textSize="20dp"
android:gravity="center"/>

<Button
android:id="@+id/on"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text"
android:layout_marginTop="62dp"
android:text="ON" />

<Button
android:id="@+id/discoverable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/on"
android:layout_marginTop="74dp"
android:text="DISCOVERABLE" />

<Button
android:id="@+id/off"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/discoverable"
android:layout_marginTop="104dp"
android:text="OFF" />

</RelativeLayout>

Menifest File:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ifcdiv">
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

Java File
package com.example.ifcdiv;
import androidx.appcompat.app.AppCompatActivity;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.os.Bundle;
Page No: 20 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {


Button on,off,dis;
int REQUEST_ENABLE=0;
int REQUEST_DIS=0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

on=findViewById(R.id.on);
off=findViewById(R.id.off);
dis=findViewById(R.id.discoverable);

BluetoothAdapter bluetoothAdapter=BluetoothAdapter.getDefaultAdapter();

on.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(!bluetoothAdapter.isEnabled())
{
Intent i=new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(i,REQUEST_ENABLE);
}
}
});

dis.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(!bluetoothAdapter.isDiscovering())
{
Intent i=new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
startActivityForResult(i,REQUEST_DIS);
}
}
});

off.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
bluetoothAdapter.disable();
}
});
}
}

Page No: 21 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
d) Explain Geocoding and reverse geocoding in android with example. 4M

Ans Geocoding: Converts an address (like "123 Main St, Mumbai") into geographical 3 M for Code,
coordinates (latitude and longitude). 1 M for
Permissions
Reverse Geocoding: Converts geographical coordinates into a readable address (like
"123 Main St, Mumbai").
Example: Geocoding and Reverse Geocoding
1. Add Permissions
Include location permissions in the AndroidManifest.xml:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
/>
2. Layout File (res/layout/activity_main.xml)
A layout with a button and two TextView elements to show results.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<Button
android:id="@+id/btnGeocode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Get Coordinates from Address" />

<TextView
android:id="@+id/tvGeocodeResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp" />
<Button

Page No: 22 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:id="@+id/btnReverseGeocode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Get Address from Coordinates"
android:layout_marginTop="20dp" />
<TextView
android:id="@+id/tvReverseGeocodeResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp" />
</LinearLayout>
3. Java Code (MainActivity.java)
Using Geocoder to perform geocoding and reverse geocoding.
package com.example.geocodingdemo;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Page No: 23 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
setContentView(R.layout.activity_main);
Button btnGeocode = findViewById(R.id.btnGeocode);
TextView tvGeocodeResult = findViewById(R.id.tvGeocodeResult);
Button btnReverseGeocode = findViewById(R.id.btnReverseGeocode);
TextView tvReverseGeocodeResult =
findViewById(R.id.tvReverseGeocodeResult);
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
// Geocoding: Address to Coordinates
btnGeocode.setOnClickListener(v -> {
String address = "123 Main St, Mumbai";
try {
List<Address> addresses = geocoder.getFromLocationName(address, 1);
if (addresses != null && !addresses.isEmpty()) {
Address location = addresses.get(0);
tvGeocodeResult.setText("Coordinates: " + location.getLatitude() + ", " +
location.getLongitude());
} else {
tvGeocodeResult.setText("Address not found");
}
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(this, "Error: " + e.getMessage(),
Toast.LENGTH_SHORT).show();
}
});
// Reverse Geocoding: Coordinates to Address
btnReverseGeocode.setOnClickListener(v -> {
double latitude = 19.0760; // Example: Mumbai's latitude
double longitude = 72.8777; // Example: Mumbai's longitude

Page No: 24 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
try {
List<Address> addresses = geocoder.getFromLocation(latitude, longitude,
1);
if (addresses != null && !addresses.isEmpty()) {
Address address = addresses.get(0);
tvReverseGeocodeResult.setText("Address: " +
address.getAddressLine(0));
} else {
tvReverseGeocodeResult.setText("Address not found");
}
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(this, "Error: " + e.getMessage(),
Toast.LENGTH_SHORT).show();
}
});
}
}

e) Explain Service Life Cycle. 4M

Ans A service is an application component which runs without direst interaction with the 1 M for diagram,
user in the background.
3 M for
● Services are used for repetitive and potentially long running operations, i.e., Internet Explanation
downloads, checking for new data, data processing, updating content providers and the
like.
● Service can either be started or bound we just need to call either startService() or
bindService() from any of our android components. Based on how our service was
started it will either be “started” or “bound”
Service Lifecycle
1. Started
a. A service is started when an application component, such as an activity, starts it by
calling startService().
b. Now the service can run in the background indefinitely, even if the component that

Page No: 25 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
started it is destroyed.

Fig: Service Lifecycle

2. Bound
a. A service is bound when an application component binds to it by calling
bindService().
b. A bound service offers a client-server interface that allows components to interact
with the service, send requests, get results, and even do so across processes with
InterProcess Communication (IPC).
c. Like any other components service also has callback methods. These will be
invoked while the service is running to inform the application of its state.
Implementing these in our custom service would help you in performing the right
operation in the right state.
d. There is always only a single instance of service running in the app. If you are
calling startService() for a single service multiple times in our application it just
invokes the onStartCommand() on that service. Neither is the service restarted
Page No: 26 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
multiple times nor are its multiple instances created
1. onCreate():
This is the first callback which will be invoked when any component starts the
service. If the same service is called again while it is still running this method Won’t
be invoked. Ideally one time setup and intializing should be done in this callback.
2. onStartCommand() /startSetvice()
This callback is invoked when service is started by any component by calling
startService(). It basically indicates that the service has started and can now run
indefinetly.
3. onBind()
To provide binding for a service, you must implement the onBind() callback method.
This method returns an IBinder object that defines the programming interface that
clients can use to interact with the service.
4. onUnbind()
This is invoked when all the clients are disconnected from the service.
5. onRebind()
This is invoked when new clients are connected to the service. It is called after
onRebind
6. onDestroy()
This is a final clean up call from the system. This is invoked just before the service is
being destroyed.

5. Attempt any TWO of the following: 12 M

a) Develop the android application for student marksheets using table layout atleast 6M
five subject marks with total and percentage. (Write both Java and xml code)

Ans <?xml version="1.0" encoding="utf-8"?> Xml file 3 M,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" Java file 3M

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:padding="16dp">

Page No: 27 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<TextView

android:id="@+id/title"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Student Marksheet"

android:textSize="24sp"

android:layout_gravity="center"

android:marginBottom="20dp" />

<TableLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:stretchColumns="1"

android:padding="8dp">

<!-- Subject 1 -->

<TableRow>

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Subject 1"

android:paddingEnd="8dp"/>

<EditText

android:id="@+id/subject1_marks"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:inputType="number"

Page No: 28 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:hint="Marks"/>

</TableRow>

<!-- Subject 2 -->

<TableRow>

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Subject 2"

android:paddingEnd="8dp"/>

<EditText

android:id="@+id/subject2_marks"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:inputType="number"

android:hint="Marks"/>

</TableRow>

<!-- Subject 3 -->

<TableRow>

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Subject 3"

android:paddingEnd="8dp"/>

<EditText

Page No: 29 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:id="@+id/subject3_marks"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:inputType="number"

android:hint="Marks"/>

</TableRow>

<!-- Subject 4 -->

<TableRow>

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Subject 4"

android:paddingEnd="8dp"/>

<EditText

android:id="@+id/subject4_marks"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:inputType="number"

android:hint="Marks"/>

</TableRow>

<!-- Subject 5 -->

<TableRow>

Page No: 30 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Subject 5"

android:paddingEnd="8dp"/>

<EditText

android:id="@+id/subject5_marks"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:inputType="number"

android:hint="Marks"/>

</TableRow>

<!-- Total and Percentage -->

<TableRow>

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Total Marks"

android:paddingEnd="8dp"/>

<TextView

android:id="@+id/total_marks"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

Page No: 31 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:text="0"

android:gravity="end"/>

</TableRow>

<TableRow>

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Percentage"

android:paddingEnd="8dp"/>

<TextView

android:id="@+id/percentage"

android:layout_width="0dp"

android:layout_height="wrap_content"

android:layout_weight="1"

android:text="0%"

android:gravity="end"/>

</TableRow>

</TableLayout>

<!-- Submit Button -->

<Button

android:id="@+id/submit_button"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Calculate"

Page No: 32 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_gravity="center"/>

</LinearLayout>

Java Code

package com.example.studentmarksheet;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;

import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

// Declare the UI components

EditText subject1, subject2, subject3, subject4, subject5;

TextView totalMarks, percentage;

Button calculateButton;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

Page No: 33 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

// Initialize the UI components

subject1 = findViewById(R.id.subject1_marks);

subject2 = findViewById(R.id.subject2_marks);

subject3 = findViewById(R.id.subject3_marks);

subject4 = findViewById(R.id.subject4_marks);

subject5 = findViewById(R.id.subject5_marks);

totalMarks = findViewById(R.id.total_marks);

percentage = findViewById(R.id.percentage);

calculateButton = findViewById(R.id.submit_button);

// Set up the calculate button click listener

calculateButton.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

// Capture the marks from the EditTexts

try {

int marks1 = Integer.parseInt(subject1.getText().toString());

int marks2 = Integer.parseInt(subject2.getText().toString());

int marks3 = Integer.parseInt(subject3.getText().toString());

int marks4 = Integer.parseInt(subject4.getText().toString());

int marks5 = Integer.parseInt(subject5.getText().toString());

// Calculate the total marks and percentage

int total = marks1 + marks2 + marks3 + marks4 + marks5;

double percentageValue = (total / 500.0) * 100;

Page No: 34 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

// Display the results

totalMarks.setText(String.valueOf(total));

percentage.setText(String.format("%.2f%%", percentageValue));

} catch (NumberFormatException e) {

// Handle the case where input is not valid

Toast.makeText(MainActivity.this, "Please enter valid marks",


Toast.LENGTH_SHORT).show();

});

b) Develop an application to store student details like roll no, name, marks and 6M
retrieve student information using roll no. in SQLite database. (Write java and
xml file).

Ans <?xml version="1.0" encoding="utf-8"?> Xml file 3 M

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" Java file 3M

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

android:padding="16dp">

<EditText

android:id="@+id/editRollNo"

android:layout_width="match_parent"

Page No: 35 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"

android:hint="Roll No"

android:inputType="number" />

<EditText

android:id="@+id/editName"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Name"

android:inputType="text" />

<EditText

android:id="@+id/editMarks"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Marks"

android:inputType="number" />

<Button

android:id="@+id/saveButton"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Save Student Info" />

<EditText

android:id="@+id/searchRollNo"

Page No: 36 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_width="match_parent"

android:layout_height="wrap_content"

android:hint="Enter Roll No to Search"

android:inputType="number" />

<Button

android:id="@+id/searchButton"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Search Student" />

<TextView

android:id="@+id/studentInfo"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Student Info will appear here"

android:textSize="18sp"

android:gravity="center"

android:layout_marginTop="20dp" />

</LinearLayout>

Java Code

package com.example.studentinfo;

import android.content.ContentValues;

import android.database.Cursor;

Page No: 37 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.database.sqlite.SQLiteDatabase;

import android.os.Bundle;

import android.view.View;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;

import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

// UI components

EditText editRollNo, editName, editMarks, searchRollNo;

Button saveButton, searchButton;

TextView studentInfo;

// SQLite helper class

DBHelper dbHelper;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

// Initialize UI components

editRollNo = findViewById(R.id.editRollNo);

Page No: 38 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
editName = findViewById(R.id.editName);

editMarks = findViewById(R.id.editMarks);

searchRollNo = findViewById(R.id.searchRollNo);

saveButton = findViewById(R.id.saveButton);

searchButton = findViewById(R.id.searchButton);

studentInfo = findViewById(R.id.studentInfo);

// Initialize DB helper

dbHelper = new DBHelper(this);

// Save button click listener

saveButton.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

saveStudentInfo();

});

// Search button click listener

searchButton.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

searchStudentInfo();

});

Page No: 39 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

// Save student info to the database

private void saveStudentInfo() {

String rollNo = editRollNo.getText().toString();

String name = editName.getText().toString();

String marks = editMarks.getText().toString();

if (rollNo.isEmpty() || name.isEmpty() || marks.isEmpty()) {

Toast.makeText(this, "Please fill all fields", Toast.LENGTH_SHORT).show();

} else {

SQLiteDatabase db = dbHelper.getWritableDatabase();

ContentValues values = new ContentValues();

values.put(DBHelper.COLUMN_ROLL_NO, rollNo);

values.put(DBHelper.COLUMN_NAME, name);

values.put(DBHelper.COLUMN_MARKS, marks);

long result = db.insert(DBHelper.TABLE_NAME, null, values);

if (result == -1) {

Toast.makeText(this, "Failed to save student info",


Toast.LENGTH_SHORT).show();

} else {

Toast.makeText(this, "Student info saved",


Toast.LENGTH_SHORT).show();

clearFields();

Page No: 40 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}

// Search student info from the database

private void searchStudentInfo() {

String rollNo = searchRollNo.getText().toString();

if (rollNo.isEmpty()) {

Toast.makeText(this, "Please enter roll number",


Toast.LENGTH_SHORT).show();

} else {

SQLiteDatabase db = dbHelper.getReadableDatabase();

String[] projection = {

DBHelper.COLUMN_ROLL_NO,

DBHelper.COLUMN_NAME,

DBHelper.COLUMN_MARKS

};

String selection = DBHelper.COLUMN_ROLL_NO + " = ?";

String[] selectionArgs = {rollNo};

Cursor cursor = db.query(DBHelper.TABLE_NAME, projection, selection,


selectionArgs, null, null, null);

if (cursor != null && cursor.moveToFirst()) {

String name =
cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.COLUMN_NAME));

Page No: 41 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
String marks =
cursor.getString(cursor.getColumnIndexOrThrow(DBHelper.COLUMN_MARKS));

studentInfo.setText("Roll No: " + rollNo + "\nName: " + name + "\nMarks: "


+ marks);

cursor.close();

} else {

studentInfo.setText("No student found with this roll number");

// Clear input fields

private void clearFields() {

editRollNo.setText("");

editName.setText("");

editMarks.setText("");

searchRollNo.setText("");

c) Explain Grid view and image view with suitable example. 6M

Ans GridView just works like ListView, The only difference is that GridView is used to Grid view
display grid of View objects. definition 1 M

The view objects can be a Text view, an Image view or a view group which has both Example of grid
an image and some text. view 2 M
Vertical and horizontal spacing between every single items of gridView can be set Image view
by verticalSpacing and horizontalSpacing. definition 1 M
Example of
GridView Example image view 2 M
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout

Page No: 42 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
xmlns: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:background="#FFEB3B"
tools:context="com.example.android.studytonightandroid.MainActivity">

<GridView
android:id="@+id/gridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
android:numColumns="2"/>
</android.support.constraint.ConstraintLayout>

Now we will create a new XML file, with name grid_item.xml in the layout folder,
and add a TextView

<?xml version="1.0" encoding="utf-8"?>


<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:padding="4dp"
android:textColor="#000000"
/>

Java File
public class MainActivity extends AppCompatActivity
{
GridView gridView;
TextView textView;
String[] carBrands = { "Ferrari", "McLaren", "Jaguar", "Skoda", "Suzuki",

Page No: 43 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
"Hyundai", "Toyota", "Renault", "Mercedes", "BMW", "Ford",
"Honda", "Chevrolet", "Volkswagon" };

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

gridView = (GridView)findViewById(R.id.gridView);
textView = (TextView)findViewById(R.id.textView);

final ArrayAdapter adapter = new ArrayAdapter(this,


android.R.layout.grid_item, android.R.id.textView, carBrands);

listView.setAdapter(adapter);

} }

ImageView

ImageView class is used to display an image file in application.

<ImageView

android:id="@+id/simpleImageView"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:background="#000"

android:src="@drawable/lion"

android:padding="30dp"/>

6. Attempt any TWO of the following: 12 M

a) Explain date picker with suitable example. 6M

Ans DatePicker is used to display date selection widget in android application. It can be Date picker
used in either spinner mode or calendar mode ( date picker). explanation 2 M
Xml file 2 M
Java file 2 M

Page No: 44 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

DatePicker Properties:
DatePickerMode :
Value can be spinner or calendar. If set to calendar, it will display a calendar which let
you choose date. If set to spinner, it will display a spinner to let you choose date.

XML file:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:paddingBottom="@dimen/activity_vertical_margin"

android:paddingLeft="@dimen/activity_horizontal_margin"

android:paddingRight="@dimen/activity_horizontal_margin"

android:paddingTop="@dimen/activity_vertical_margin"

tools:context=".MainActivity">

<DatePicker

android:id="@+id/simpleDatePicker"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:background="#150"

android:datePickerMode="spinner" />

<Button

android:id="@+id/submitButton"

android:layout_width="200dp"

android:layout_height="wrap_content"

android:layout_below="@+id/simpleDatePicker"

Page No: 45 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_centerHorizontal="true"

android:layout_marginTop="50dp"

android:background="#150"

android:text="SUBMIT"

android:textColor="#fff"

android:textSize="20sp"

android:textStyle="bold" />

</RelativeLayout>

Java File:

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.widget.DatePicker;

import android.widget.Button;

import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

DatePicker simpleDatePicker;

Button submit;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

Page No: 46 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
setContentView(R.layout.activity_main);

simpleDatePicker = (DatePicker) findViewById(R.id.simpleDatePicker);

submit = (Button) findViewById(R.id.submitButton);

submit.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

String day = "Day = " + simpleDatePicker.getDayOfMonth();

String month = "Month = " + (simpleDatePicker.getMonth() + 1);

String year = "Year = " + simpleDatePicker.getYear();

Toast.makeText(getApplicationContext(), day + "\n" + month + "\n" + year,


Toast.LENGTH_LONG).show();

});

b) Write a program to find the direction from ·user's current location to MSBTE, 6M
Bandra (Write only java and manifest file) )

Ans AndroidManifest.xml Manifest file 2


M
<?xml version="1.0" encoding="utf-8"?>
Java file 4 M
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.msbte.google_map_currentlocationroute">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
/>

Page No: 47 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
MainActivity.java
import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.net.Uri;
import android.provider.Settings;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

Page No: 48 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.karumi.dexter.Dexter;
import com.karumi.dexter.MultiplePermissionsReport;
import com.karumi.dexter.PermissionToken;
import com.karumi.dexter.listener.DexterError;
import com.karumi.dexter.listener.PermissionRequest;
import com.karumi.dexter.listener.PermissionRequestErrorListener;
import com.karumi.dexter.listener.multi.MultiplePermissionsListener;
import java.util.List;
public class MainActivity extends AppCompatActivity implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
com.google.android.gms.location.LocationListener , OnMapReadyCallback,
TaskLoadedCallback{
//variables for map and route
private GoogleMap mMap;
private MarkerOptions place1, place2;
Button getDirection;
private Polyline currentPolyline;
private MapFragment mapFragment;
private boolean isFirstTime = true;
//variables for current location
private static final String TAG = "MainActivity";
private TextView tvLocation;
private GoogleApiClient mGoogleApiClient;
private Location mLocation;
private LocationRequest mLocationRequest;
private com.google.android.gms.location.LocationListener listener;

Page No: 49 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
private long UPDATE_INTERVAL = 2 * 1000; /* 10 secs */
private long FASTEST_INTERVAL = 2000; /* 2 sec */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//code for getting current location
requestMultiplePermissions();
tvLocation = (TextView) findViewById((R.id.tv));
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
} //code for drawing route
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.clear();
Log.d("mylog", "Added Markers");
mMap.addMarker(place1);
mMap.addMarker(place2);
CameraPosition googlePlex = CameraPosition.builder()
.target(new LatLng(22.7739,71.6673))
.zoom(7)
.bearing(0)
.tilt(45)
.build();
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(googlePlex),
Page No: 50 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
5000,
null);
}
private String getUrl(LatLng origin, LatLng dest, String directionMode) {
// Origin of route
String str_origin = "origin=" + origin.latitude + "," + origin.longitude;
// Destination of route
String str_dest = "destination=" + dest.latitude + "," + dest.longitude;
// Mode
String mode = "mode=" + directionMode;
// Building the parameters to the web service
String parameters = str_origin + "&" + str_dest + "&" + mode;
// Output format
String output = "json";
// Building the url to the web service
String url = "https://maps.googleapis.com/maps/api/directions/" + output + "?" +
parameters + "&key=" + getString(R.string.google_maps_key);
return url;
}
@Override
public void onTaskDone(Object... values) {
if (currentPolyline != null)
currentPolyline.remove();
currentPolyline = mMap.addPolyline((PolylineOptions) values[0]);
}
//runtime permission method
private void requestMultiplePermissions(){
Dexter.withActivity(this)

Page No: 51 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
withPermissions(
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.ACCESS_COARSE_LOCATION )
.withListener(new MultiplePermissionsListener() {
@Override
public void onPermissionsChecked(MultiplePermissionsReport report) {
// check if all permissions are granted
if (report.areAllPermissionsGranted()) {
Toast.makeText(getApplicationContext(), "All permissions are granted by
user!", Toast.LENGTH_SHORT).show();
}
// check for permanent denial of any permission
if (report.isAnyPermissionPermanentlyDenied()) {
// show alert dialog navigating to Settings
openSettingsDialog();
}
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest>
permissions, PermissionToken token) {
token.continuePermissionRequest();
}
}).
withErrorListener(new PermissionRequestErrorListener() {
@Override
public void onError(DexterError error) {
Toast.makeText(getApplicationContext(), "Some Error! ",
Toast.LENGTH_SHORT).show();

Page No: 52 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}
})
.onSameThread()
.check();
}
private void openSettingsDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle("Required Permissions");
builder.setMessage("This app require permission to use awesome feature. Grant them
in
app settings.");
builder.setPositiveButton("Take Me To SETTINGS", new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
Intent intent = new
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivityForResult(intent, 101);
}
});
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});

Page No: 53 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
builder.show();
}
//methods for getting current location
@Override
public void onConnected(Bundle bundle) {
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
return;
}
startLocationUpdates();
mLocation =
LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
if(mLocation == null){
startLocationUpdates();
}
if (mLocation != null) {
// mLatitudeTextView.setText(String.valueOf(mLocation.getLatitude()));
//mLongitudeTextView.setText(String.valueOf(mLocation.getLongitude()));
} else {
Toast.makeText(this, "Location not Detected", Toast.LENGTH_SHORT).show();
}}
@Override
public void onConnectionSuspended(int i) {
Log.i(TAG, "Connection Suspended");
mGoogleApiClient.connect();

Page No: 54 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.i(TAG, "Connection failed. Error: " + connectionResult.getErrorCode());
}
@Override
protected void onStart() {
super.onStart();
if (mGoogleApiClient != null) { mGoogleApiClient.connect();
}}
@Override
protected void onStop() {
super.onStop();
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}}
protected void startLocationUpdates() {
// Create the location request
mLocationRequest = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
.setInterval(UPDATE_INTERVAL)
.setFastestInterval(FASTEST_INTERVAL);
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
return;

Page No: 55 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,
mLocationRequest, this);
}
@Override
public void onLocationChanged(Location location) {
String msg = "Updated Location: " +
Double.toString(location.getLatitude()) + "," +
Double.toString(location.getLongitude());
tvLocation.setText(String.valueOf(location.getLatitude() +"
"+String.valueOf(location.getLongitude())));
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
if(isFirstTime){
//code to draw path on map
getDirection = findViewById(R.id.btnGetDirection);
getDirection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new FetchURL(MainActivity.this).execute(getUrl(place1.getPosition(),
place2.getPosition(), "driving"), "driving");
}
});
place1 = new MarkerOptions().position(new LatLng(location.getLatitude(),
location.getLongitude())).title("Location 1");
place2 = new MarkerOptions().position(new
LatLng(19.021824,72.8662016)).title("MSBTE");
mapFragment = (MapFragment)
getFragmentManager().findFragmentById(R.id.mapNearBy);

Page No: 56 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
mapFragment.getMapAsync(this);
isFirstTime = false;
} }}
Note: Imports are not required in coding.

c) Develop and application to send SMS (Design minimal UI as per your choice. 6M
Write XML ,Java and manifest file).

Ans activity_main.xml: Manifest file 1


M
MainActivity.java:
package com.example.al_libaansapp; Xml file 2 M
import androidx.appcompat.app.AppCompatActivity; Java file 3 M
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {


SmsManager sm;
Button send;
EditText msg, phone;

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

send = findViewById(R.id.send);
msg = findViewById(R.id.sms);
phone = findViewById(R.id.phone);

requestMessage();

send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Page No: 57 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
if(checkPermission()) {
sendSMS();
} else {
requestMessage();
}
}
});
}

public void requestMessage(){


ActivityCompat.requestPermissions(this, new
String[]{Manifest.permission.SEND_SMS},0);
}
public void sendSMS(){
try {
String PhoneText = phone.getText().toString();
String MsgTxt = msg.getText().toString();

sm = SmsManager.getDefault();
sm.sendTextMessage(PhoneText , null, MsgTxt,null,null);
Toast.makeText(MainActivity.this, "Message sent",
Toast.LENGTH_SHORT).show();
} catch (Exception e) {
Toast.makeText(MainActivity.this, "Message not sent",
Toast.LENGTH_SHORT).show();
}
}
public boolean checkPermission(){
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.SEND_SMS) ==
PackageManager.PERMISSION_GRANTED) {
return true;
} else return false;
}
}
AndroidManifest.xml:
o <uses-feature android:name="android.hardware.telephony" />
o <uses-permission
android:name="android.permission.SEND_SMS"/>

Note: Consider the simple code.

Page No: 58 | 58
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
SUMMER – 2024 EXAMINATION
Model Answer – Only for the Use of RAC Assessors

Subject Name: Mobile Application Development Subject Code: 22617


Important Instructions to examiners: XXXXX
1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not applicable for
subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The figures drawn
by candidate and model answer may vary. The examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may vary and
there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based on
candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual (English +
Marathi) medium is introduced at first year of AICTE diploma Programme from academic year 2021-2022. Hence if
the students in first year (first and second semesters) write answers in Marathi or bilingual language (English
+Marathi), the Examiner shall consider the same and assess the answer based on matching of concepts with model
answer.

Q. Su Answer Marking
No b Scheme
. Q.
N.

1 Attempt any FIVE of the following: 10 M

a) List any four features of android operating system. 2M

An Features of Android Operating System: Any 4 one


s 1)Storage for ½ M
2)Multitasking
3)Web Browser
4)Open Source
5)Accessibility
6)Media Support
7)Streaming Media Support
8)Voice Based Features
9)Multitouch
10)External Storage
11)Video Calling
12)Handset Layout
13)Google cloud Messaging
14)WiFi Direct
b) Describe role of Emulator. 2M

Page No: 1 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
An Android emulator is a tool that creates virtual Android devices on your computer. The Correct
s emulator lets you prototype, develop and test Android applications without using a physical definition
device 2M

c) List various components of android UI design. 2M

An Components of android UI design: One for ½


s M
1)views

2)viewgroups

3)fragments

4)activity

d) List any two attributes of Toggle Button. 2M

An 1. android:textOff any 2
s 2. android:textOn attributes ,
3. android:id one
4. android:checked attribute
5. android:gravity for one M
6. android:textColor
7. android:textSize
8. android: textStyle
e) Define service in android operating system. 2M

An A service is an application component which runs without direct interaction with the user in Correct
s the background. Services are used for repetitive and potentially long running operations, i.e., definition
Internet downloads, checking for new data, data processing, updating content providers and 2M
the like.

f) Explain two methods of Google Map. 2M

An getMyLocation(): This method returns the currently displayed user location. One
s method for
moveCamera(CameraUpdate update): This method reposition the camera according to the 1M
instructions defined in the update.

g) Write down syntax to create an intent and start another activity. 2M

An Intent i = new Intent(this, ActivityTwo.class); //create intent create


s intent for 1
startActivity(i); //start activity M and start
activity 1
M

Page No: 2 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

2. Attempt any THREE of the following: 12 M

a) Explain need of android. 4M

An Android is a new generation mobile OS which runs on Linux kernel. There are some Any four
s following points which describe why we use Android OS: points,
1. Desktop: The Android phone adds widgets to the desktop. The purpose for the widget, 4M
for
example, the Facebook widget allows us to update our facebook desktop. The people widget
allows us to make possible different actions for different contacts right from our desktop.
The
message widget allows us to immediately see our e-mail from the desktop.

2. Connectivity: On one page/desktop we could be able to have four connecting device tool
button like, Turn ON/OFF Bluetooth, Turn ON/OFF WiFi, Turn ON/OFF mobile network,
Turn On/Off GPS and so on. These buttons let us switch ON/OFF instantly which will help
us to conserve battery life.

3. Browser: The Android OS browser is one of the best browsers on the mobile market. It
generally loads pages faster than Safari or any other browser, has Flash support and simply
does everything a browser should do. For example, iPhone has Safari browser. It is stable,
has no Flash support, so we cannot watch Youtube videos or any related contents, it is not
flexible but monopolistic.

4. Open to Carrier: If we know Java programming language then we are open to Android
world.

5. Market: Android OS has an android market. The android apps are free and work as well.

6. Future: The future mobile phones are basically going to be smart phones.

7. Muti-Notification: Android phones have multi-notification system. With android the app
have access to the notification system and call all report.

8. Google Integration: The Android has inbuilt google support. For examle, Google Map,
G-Mail etc.

9. Open Source: The code of android OS as well as the apps is available.

10. Endless Personalization: The Android cell phone allows to configuration their mobile
to look and behave exactly like they want.
b) Compare JVM and DVM. (any four points) 4M

An Any four
s JVM DVM points 4
M, 1 M for
one point)

Page No: 3 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
JVM supports multiple operating DVM supports only Android Operating
systems. System.

JVM forms separate classes in separate DVM forms multiple class in .dex byte
code file.
.class byte code files.

It is based on stack based virtual machine It is based on Register based virtual


architecture. machine architecture.

JVM runs on more memory. DVM runs on less memory.

The executable format of JVM is JAR. The executable format of DVM is APK.

JVM has different constant pools. DVM has common constant pool.

It runs .class byte code directly. The .class byte codes are optimized to
.odex format before executing in DVM.

c) Explain android security model. 4M

An Android is a multi-process system, in which each application (and parts of the system) runs correct
s in its own process. explanatio
n4M
Most security between applications and the system is enforced at the process level through
standard Linux facilities, such as user and group IDs that are assigned to applications.

Additional finer-grained security features are provided through a “permission” mechanism


that enforces restrictions on the specific operations that a particular process can perform, and
per-URI permissions for granting ad-hoc access to specific pieces of data.

The Android security model is primarily based on a sandbox and permission mechanism.
Each application is running in a specific Dalvik virtual machine with a unique user ID
assigned to it, which means the application code runs in isolation from the code of all others
applications. As a consequence, one application has not granted access to other applications’
files.

Android application has been signed with a certificate with a private key Know the owner of
the application is unique.

This allows the author of The application will be identified if needed.

When an application is installed in The phone is assigned a user ID, thus avoiding it from
affecting it Other applications by creating a sandbox for it. This user ID is permanent on
which devices and applications with the same user ID are allowed to run in a single process.
This is a way to ensure that a malicious application has Can not access / compromise the data
of the genuine application.

Page No: 4 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
It is mandatory for an application to list all the resources it will Access during installation.

The purpose of a permission is to protect the privacy of an Android user. Android apps must
request permission to access sensitive user data (such as contacts and SMS), as well as certain
system features (such as camera and internet).

Permissions are divided into several protection levels. The protection level affects whether
runtime permission requests are required.

Android introduced shared user ID & permission to allow application components talk to
each other & enable application to access to critical system in Android devices.

d) Draw and explain activity life cycle. 4M

Page No: 5 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
An Diagram
s 2M,
Explanati
on 2 M

onCreate (): Called then the activity is created. Used to initialize the activity, for example
create the user interface.

onStart ():called when activity is becoming visible to the user.

onResume (): Called if the activity get visible again and the user starts interacting with the
activity again. Used to initialize fields, register listeners, bind to services, etc.

onPause (): Called once another activity gets into the foreground. Always called before the
activity is not visible anymore. Used to release resources or save application data. For

Page No: 6 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
example you unregister listeners, intent receivers, unbind from services or remove system
service listeners.

onStop (): Called once the activity is no longer visible. Time or CPU intensive shutdown
operations, such as writing information to a database should be down in the onStop() method.
This method is guaranteed to be called as of API 11.

onDestroy (): called before the activity is destroyed.

1. Activity States:
The Android OS uses a priority queue to assist in managing activities running on the device.
Based on the state a particular Android activity is in, it will be assigned a certain priority
within the OS. This priority system helps Android identify activities that are no longer in
use, allowing the OS to reclaim memory and resources. Fig. illustrates the states an activity
can go through, during its lifetime:
These states are often broken into three main teams as follows:
1. Active or Running:
Activities are thought of active or running if they're within the foreground, additionally
referred to as the top of the activity stack. this can be thought of the highets priority activity
within the Android Activity stack, and as such only be killed by the OS in extreme things,
like if the activity tries to use more memory than is available on the device as this might
cause the UI to become unresponsive.
2. Paused:
When the device goes to sleep, or an activity continues to be visible but partially hidden by
a new, non-full-sized or clear activity, the activity is taken into account paused. Paused
activities are still alive, that is, they maintain all state and member information, and stay
attached to the window manager. This can be thought of to be the second highest priority
activity within the android Activity stack and, as such, can solely be killed by the OS if
killing this activity can satisfy the resource requirement needed to keep the Active/Running
Activity stable and responsive.
3. Stopped:
Activities that are utterly obscured by another activity are thought of stopped or within the
background. Stopped activities still try and retain their state and member info for as long as
possible but stopped activities are thought of to be loweat priority of the three states and, as
such, the OS can kill activities during this state initial to satisfy the resource needs of higher
priority activities.

3. Attempt any THREE of the following: 12 M

a) Describe various installation steps of android studio and its environment. 4M

An Steps to install Android studio and SDK Android


s studio
Pre-Installation Check List installation
1. Before installing Android SDK, there is need to install Java Development Kit (JDK). steps 3 M
Ensure that JDK is at or above 1.8.
2. Uninstall older version(s) of "Android Studio" and "Android SDK", if any. SDK 1 M

Page No: 7 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
We need to install two packages:
1. Android Studio (IDE), which is an Integrated Development Environment (IDE)
2. Android SDK (Software Development Kit) for developing and running Android apps.

Steps to install Android studio:


Download Android Studio
1. Click Download Android Studio. The Terms and Conditions page with the Android Studio
License Agreement opens.
2. Read the License Agreement.
3. At the bottom of the page, if you agree with the terms and conditions, select the I have
read and agree with the above terms and conditions checkbox.
4. Click Download Android Studio to start the download.
5. When prompted, save the file to a location where you can easily locate it, such as the
Downloads folder.
6. Wait for the download to complete.

Install Android Studio


a) Open the folder where you downloaded and saved the Android Studio installation file.
b) Double-click the downloaded file.
c) If you see a User Account Control dialog about allowing the installation to make changes
to your computer, click Yes to confirm the installation.
d) Click Next to start the installation.
e) Accept the default installation settings for all steps.
f) Click finish when installation is done.

Installing Android SDK


Within Android Studio, you can install the Android SDK as follows:
1. Click Tools > SDK Manager.
2. In the SDK Platforms tab, select Android Tiramisu Preview.
3. In the SDK Tools tab, select Android SDK Build.
4. Click OK to install the SDK.
b) Explain scrollview with its attributes and with suitable example. 4M

An ScrollView Explain:
s 1M
ScrollView is used to scroll the child elements of palette inside ScrollView. Android
supports vertical scroll view as default scroll view. Vertical ScrollView scrolls elements Attributes:
vertically.Android uses HorizontalScrollView for horizontal ScrollView. 1M
Example :
Attributes of ScrollView 2M
• android:fillViewport - Defines whether the scrollview should stretch its content to
fill the viewport.
• android:scrollbars - scrollbars attribute is used to show the scrollbars in horizontal
or vertical direction
• android:layout_width – Define the width
• android:layout_height – Define height
• android:id – Define id

Page No: 8 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Example :
<?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:paddingLeft="10dp"
android:paddingRight="10dp">

<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/scrollView">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 1"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 2"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 3"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 4"/>
</LinearLayout>
</ScrollView>
</LinearLayout>

c) Write significance of SQLite database in android. 4M

An • SQLite is an open-source relational database i.e. used to perform database Any 4


s points :
operations on android devices such as storing, manipulating or retrieving persistent
4M
data from the database.
• It is embedded in android bydefault. So, there is no need to perform any database
setup or administration task.

Page No: 9 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• SQLite is one way of storing app data. It is very lightweight database that comes
with Android OS.
• By default, Android comes with built-in SQLite Database support so we don’t need
to do any configurations.
• Android stores our database in a private disk space that’s associated with our
application and the data is secure, because by default this area is not accessible to
other applications.
• The package android.database.sqlite contains all the required APIs to use an SQLite
database in our android applications.
• In android, by using SQLiteOpenHelper class we can easily create the required
database and tables for our application. To use SQLiteOpenHelper, we need to
create a subclass that overrides the onCreate() and onUpgrade() call-back methods.
• SQLiteDatabase class contains methods to be performed on sqlite database such
as create, update, delete, select etc.
• We can insert data into the SQLite database by
passing ContentValues to insert() method.
• In android, we can read the data from the SQLite database using
the query() method in android applications.
We can update the data in the SQLite database using an update() method in android
applications.

d) Explain importance or use of developer console. 4M

An Google Play Developer Console is the platform that Google provides for Google Play and Any 4
s Android developers to publish their apps. points :
4M
● The Google Play Developer console allows app developers and marketers to better
understand how their apps are performing in terms of growth, technical performance such as
crashes or display issues, and financials.

● The console offers acquisition reports and detailed analysis which can help app devs find
out how well an app is really performing.

● The platform is important as it provides developers with access to first party data
(trustworthy information collected about an app’s audience that comes straight from Google
Play) that highlights the real performance of an app.

● It shows the number of impressions an app listing receives and the number of Installs an
app receives from different sources over time.

Page No: 10 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

4. Attempt any THREE of the following: 12 M

a) Describe linear layout and frame layout with example. 4M

An 1. Linear Layout Linear


s Linear Layout is a ViewGroup that is responsible for holding views in it. It is a layout that layout :
arranges its children i.e the various views and layouts linearly in a single column(vertically) 2M
or a single row(horizontally). Frame
layout : 2
Whether all the children will be arranged horizontally or vertically depends upon the value
M
of attribute android:orientation. By default the orientation is horizontal.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"

android:orientation="vertical" >

<Button

android:id="@+id/btnStartService"

android:layout_width="270dp"

android:layout_height="wrap_content"

android:text="Button 1"/>

<Button

android:id="@+id/btnStopService"

android:layout_width="270dp"

android:layout_height="wrap_content"

android:text="Button 2"/>

</LinearLayout>

2. Frame Layout
FrameLayout is designed to block out an area on the screen to display a single item.
Generally, FrameLayout should be used to hold a single child view, because it can be difficult

Page No: 11 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
to organize child views in a way that's scalable to different screen sizes without the children
overlapping each other.

We can add multiple children to a FrameLayout and control their position within the
FrameLayout by assigning gravity to each child, using the android:layout_gravity attribute.

Example:

<FrameLayout

xmlns: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:id="@+id/table"

android:foregroundGravity="center"

android:foreground="#000"

tools:context=".MainActivity">

<ImageView

android:layout_width="200dp"

android:layout_height="200dp"

android:layout_marginBottom="10dp"

android:src="@mipmap/ic_launcher"

android:scaleType="centerCrop" />

<TextView

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_gravity=""

android:text="CENTER"/>

</FrameLayout>

Page No: 12 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
b) Write a program to create first display screen of any search engine using auto complete 4M
text view.
An <RelativeLayout Xml file:
s 1M
xmlns:android="http://schemas.android.com/apk/res/android"
Java file: 3
xmlns:app="http://schemas.android.com/apk/res-auto" M
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:layout_gravity="center">

<AutoCompleteTextView
android:id="@+id/txt"
android:textSize="50dp"
android:layout_centerHorizontal="true"
android:hint="Enter Text to search"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>

package com.example.al_libaansapp;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;

Page No: 13 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.view.View;
import android.widget.AutoCompleteTextView;
import android.widget.Button;

public class MainActivity extends AppCompatActivity


{
String[] fruits = {"apple", "mango", "banana", "kiwi", "pineapple", "guava", "grapes",
"orange", "watermelon", "papaya"};
AutoCompleteTextView txt;

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

txt = findViewById(R.id.txt);

ArrayAdapter adp = new ArrayAdapter(this,


android.R.layout.simple_dropdown_item_1line, fruits);
txt.setThreshold(1);
txt.setAdapter(adp);
}
}

c) What is fragment? Explain with example. 4M

An • Android Fragment is the part of activity, it is also known as sub-activity. There can Define
s Fragment :
be more than one fragment in an activity.
2M

• Fragments represent multiple screen inside one activity. Example:


2M

Page No: 14 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• We can create Fragments by extending Fragment class or by inserting a Fragment
into our Activity layout by declaring the Fragment in the activity’s layout file, as
a <fragment> element.

• We can combine multiple Fragments in a single activity to build a multi-plane UI.

• We can only show a single Activity on the screen at one given point of time so we
were not able to divide the screen and control different parts separately. With the
help of Fragment’s we can divide the screens in different parts and controls
different parts separately.

Example:
activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns: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:orientation="vertical"
android:gravity="center"
tools:context=".MainActivity">

<fragment
android:id="@+id/Frag1"
android:layout_width="match_parent"
android:layout_height="400dp"
android:name="com.example.al_libaansapp"/>
<fragment
android:id="@+id/Frag2"
android:layout_width="match_parent"
android:layout_height="400dp"
android:name="com.example.al_libaansapp"/>
</LinearLayout>

- Fragment1.xml:

<?xml version="1.0" encoding="utf-8"?>


<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
Page No: 15 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
tools:context=".Fragment1">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Fragment 1"
android:textSize="40dp"
android:textColor="@color/white"
android:textStyle="bold" />

</FrameLayout>

- Fragment2.xml:

<FrameLayout

xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/purple"
tools:context=".Fragment2">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Fragment 2"
android:textSize="40dp"
android:textStyle="bold"
android:textColor="@color/black"/>

</FrameLayout>

d) Describe types of permissions used while developing android application. 4M

Page No: 16 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
An Each type :
s Types of permissions 1M

1. Install-time permissions

• Install-time permissions give your app limited access to restricted data, and they
allow your app to perform restricted actions that minimally affect the system or
other apps.

• When you declare install-time permissions in your app, the system automatically
grants your app the permissions when the user installs your app.

Android includes several sub-types of install-time permissions,

Normal permissions and Signature permissions.

a) Normal permissions

• These permissions allow access to data and actions that extend beyond your app's
sandbox.

• However, the data and actions present very little risk to the user's privacy, and the
operation of other apps.

b) Signature permissions

• If the app declares a signature permission that another app has defined, and if the
two apps are signed by the same certificate, then the system grants the permission
to the first app at install time. Otherwise, that first app cannot be granted the
permission.

2. Runtime permissions

• Runtime permissions, also known as dangerous permissions, give your app


additional access to restricted data, and they allow your app to perform restricted
actions that more substantially affect the system and other apps.

• Many runtime permissions access private user data, a special type of restricted data
that includes potentially sensitive information. Examples of private user data
include location and contact information.

• The system assigns the "dangerous" protection level to runtime permissions.

3. Special permissions

• Special permissions correspond to particular app operations.

Page No: 17 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• Only the platform and OEMs can define special permissions.

Additionally, the platform and OEMs usually define special permissions when they want to
protect access to particularly powerful actions, such as drawing over other apps.

e) Develop a program to send an SMS. 4M

An AndroidManifest.xml Xml file:


s 2M
<uses-permission android:name="android.permission.SEND_SMS"/>
Java File :
activity_main.xml
2M
<?xml version="1.0" encoding="utf-8"?>

<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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"

tools:context=".MainActivity">

<TextView

android:id="@+id/textView"

android:layout_width="81dp"

android:layout_height="41dp"

android:layout_marginEnd="268dp"

android:layout_marginBottom="576dp"

android:text="To :"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"/>

<TextView

android:id="@+id/textView2"

android:layout_width="70dp"

Page No: 18 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="43dp"

android:layout_marginEnd="276dp"

android:layout_marginBottom="512dp"

android:text="Sms Text"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent" />

<EditText

android:id="@+id/etPhno"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginEnd="40dp"

android:layout_marginBottom="572dp"

android:ems="10"

android:inputType="textPersonName"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent" />

<EditText

android:id="@+id/etmsg"

android:layout_width="193dp"

android:layout_height="51dp"

android:layout_marginEnd="56dp"

android:layout_marginBottom="504dp"

android:inputType="textPersonName"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent" />

<Button

Page No: 19 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:id="@+id/btnSms"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginEnd="156dp"

android:layout_marginBottom="400dp"

android:text="SEND SMS"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java

public class MainActivity extends AppCompatActivity

EditText et1,et2;

Button b1;

@Override

protected void onCreate(Bundle savedInstanceState)

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

et1=findViewById(R.id.etPhno);

et2=findViewById(R.id.etmsg);

b1=findViewById(R.id.btnSms);
if(ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.SEND_SMS)!
=

PackageManager.PERMISSION_GRANTED)

ActivityCompat.requestPermissions(MainActivity.this,new

Page No: 20 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
String[]{Manifest.permission.SEND_SMS},100);

b1.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

try {

String phno= et1.getText().toString();

String msg=et2.getText().toString();

SmsManager smsManager= SmsManager.getDefault();

smsManager.sendTextMessage(phno,null,msg,null,null);
Toast.makeText(MainActivity.this,"Sms sent successfully",
Toast.LENGTH_LONG).show();

catch(Exception e)

Toast.makeText(MainActivity.this,"Sms failed to send... try again",


Toast.LENGTH_LONG).show();

});

5. Attempt any TWO of the following: 12 M

a) Develop android application to enter one number and display factorial of a number 6M
once click on button.

An (Note: Consider the appropriate XML file. All attributes are not required. xml file-
s In java file all imports are not expected. Different relevant logic/code can be 2M
considered.)
java code-
activity_main.xml 4M

Page No: 21 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns: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"
tools:context=".MainActivity">

<EditText
android:layout_width="wrap_content"
android:layout_height=" wrap_content "
android:hint="Enter a number"
android:id="@+id/number"
android:inputType="number"
android:textSize="30dp"
/>

<Button
android:layout_width=" wrap_content "
android:layout_height="wrap_content"
android:id="@+id/btn1"
android:layout_below="@id/number"
android:textSize="20dp"
android:text="Calculate Factorial"
/>

<TextView
android:layout_width="wrap_content"

Page No: 22 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"
android:id="@+id/tv"
android:layout_below="@id/btn1"
android:textSize="20dp"/>
</RelativeLayout>

MainActivity.java
package com.example.factorial;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {


EditText number;
Button btn1;
TextView tv;
int num;
int factor;
String s;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
number=(EditText)findViewById(R.id.number);
btn1=(Button)findViewById(R.id.btn1);

Page No: 23 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
tv=(TextView)findViewById(R.id.tv);

btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String strnum;
strnum = number.getText().toString();
num = Integer.parseInt(strnum);
factorial(num);

}
});
}
private void factorial(int num) {
int i = 1;
factor = i;
while (i <= num) {
factor = factor * i;
i++;
}
s = ”Factorial of Number is : ”+ factor;
tv.setText(s);
}
}

b) Write a program to capture an image using camera and display it. 6M

An (Note: Consider the appropriate XML file. All attributes are not required. XML file-
s In java file all imports are not expected. Different relevant logic/code can be 2M
considered.)
Java code-
4M

Page No: 24 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns: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="40dp"
android:orientation="horizontal"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CAMERA"
android:id="@+id/text"
android:textSize="20dp"
android:gravity="center"/>
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text"
android:layout_marginTop="81dp"
android:src="@drawable/rose"/>
<Button
android:id="@+id/photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/image"

Page No: 25 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="TAKE PHOTO" />
</RelativeLayout>

MainActivity.java
package com.example.ifcdiv;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Bitmap; import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class MainActivity extends AppCompatActivity {
Button b1;
ImageView imageView;
int CAMERA_REQUEST=1;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
b1=findViewById(R.id.photo); imageView=findViewById(R.id.image);
b1.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
Intent i=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(i,CAMERA_REQUEST); } }); }
@Override protected void onActivityResult(int requestCode, int resultCode, @Nullable
Intent data) { super.onActivityResult(requestCode, resultCode, data);
if (requestCode==CAMERA_REQUEST) { Bitmap image= (Bitmap)
data.getExtras().get("data");
imageView.setImageBitmap(image); } } }

Page No: 26 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
c) Write a program to show users current location. 6M

An (Note: Consider the appropriate XML file. All attributes are not required. In java file all XML file:
s imports are not expected.) 1M

Java Code:
activity_main.xml 5M
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns: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"
tools:context=".MainActivity">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/google_map"
android:name="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>

MainActivity.Java
package com.example.location;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.FragmentActivity;
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import android.widget.Toast;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
public class MainActivity extends FragmentActivity implements
OnMapReadyCallback
{
Location currentlocation;
FusedLocationProviderClient fusedLocationProviderClient;

Page No: 27 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
private static final int REQUEST_CODE = 101;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
fetchLastLocation();
}
private void fetchLastLocation() {
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission
(this, Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,new
String[]{Manifest.permission.ACCESS_FINE_LOCATION},REQUEST_CODE);
return;
}
Task<Location> task = fusedLocationProviderClient.getLastLocation();
task.addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
if(location!=null)
{
currentlocation=location;
Toast.makeText(getApplicationContext(),currentlocation.getLatitude()+""+
currentlocation.getLongitude(), Toast.LENGTH_SHORT).show();
SupportMapFragment supportMapFragment =
(SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.google_ma
p);
supportMapFragment.getMapAsync(MainActivity.this);
}
}
});
}
@Override
public void onMapReady(@NonNull GoogleMap googleMap) {
LatLng latLng=new LatLng(currentlocation.getLatitude(),currentlocation.getLongitude());
MarkerOptions markerOptions=new MarkerOptions().position(latLng)
.title("I am Here");
googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng,5));
googleMap.addMarker(markerOptions);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
Page No: 28 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
case REQUEST_CODE:
if (grantResults.length > 0 && grantResults[0] ==
PackageManager.PERMISSION_GRANTED) {
fetchLastLocation();
}
break;
}
}
}

6. Attempt any TWO of the following: 12 M

a) Write a program to display the list of sensors supported by device. 6M

An (Note: Consider the appropriate XML file. All attributes are not required. In java file Xml file-
s all imports are not expected. Different relevant logic/code can be considered.) 2M
Java code-
activity_main.xml 4M

<?xml version="1.0" encoding="UTF-8"?>


<LinearLayout
android:paddingRight="10dp"
android:paddingLeft="10dp"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:visibility="gone"
android:layout_gravity="center"
android:textStyle="bold"
android:textSize="20dp"
android:text="Sensors"
android:layout_marginTop="80dp"
android:id="@+id/sensorslist"/>

</LinearLayout>

MainActivtiy.java
Package com.example.sensordisplay;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.view.View;
Page No: 29 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.widget.TextView;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private SensorManager mgr;
private TextView txtList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mgr = (SensorManager)getSystemService(Context.SENSOR_SERVICE);
txtList = (TextView)findViewById(R.id.sensorslist);
List<Sensor> sensorList = mgr.getSensorList(Sensor.TYPE_ALL);
StringBuilder strBuilder = new StringBuilder();
for(Sensor s: sensorList){
strBuilder.append(s.getName()+"\n");
}
txtList.setVisibility(View.VISIBLE);
txtList.setText(strBuilder);
}
}
b) Write a program to send e-mail. 6M

An (Note: Consider the appropriate XML file. All attributes are not required. Xml file-
s Different relevant logic/code can be considered.) 2M

activity_main.xml Java code-


4M
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText

android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginTop="18dp"
android:layout_marginRight="22dp" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText1"
android:layout_alignLeft="@+id/editText1"
android:layout_marginTop="20dp" />

Page No: 30 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<EditText
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText2"
android:layout_alignLeft="@+id/editText2"
android:layout_marginTop="30dp" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText1"
android:layout_alignBottom="@+id/editText1"
android:layout_alignParentLeft="true"
android:text="Send To:"
android:textColor="#0F9D58" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText2"
android:layout_alignBottom="@+id/editText2"
android:layout_alignParentLeft="true"
android:text="Email Subject:"
android:textColor="#0F9D58" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText3"
android:layout_alignBottom="@+id/editText3"
android:text="Email Body:"
android:textColor="#0F9D58" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText3"
android:layout_alignLeft="@+id/editText3"

android:layout_marginLeft="76dp"
android:layout_marginTop="20dp"
android:text="Send email!!" />
</RelativeLayout>

MainActivity.java
package com.example.email;
import android.content.Intent;
Page No: 31 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
// define objects for edit text and button
Button button;
EditText sendto, subject, body;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Getting instance of edittext and button
sendto = findViewById(R.id.editText1);
subject = findViewById(R.id.editText2);
body = findViewById(R.id.editText3);
button = findViewById(R.id.button);
// attach setOnClickListener to button with Intent object define in it
button.setOnClickListener(view -> {
String emailsend = sendto.getText().toString();
String emailsubject = subject.getText().toString();
String emailbody = body.getText().toString();
// define Intent object with action attribute as ACTION_SEND
Intent intent = new Intent(Intent.ACTION_SEND);
// add three fields to intent using putExtra function
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{emailsend});
intent.putExtra(Intent.EXTRA_SUBJECT, emailsubject);
intent.putExtra(Intent.EXTRA_TEXT, emailbody);
// set type of intent
intent.setType("message/rfc822");
// startActivity with intent with chooser as Email client using createChooser function
startActivity(Intent.createChooser(intent, "Choose an Email client :"));
});
}
}
c) Write a program to show five checkboxes and total selected checkboxes using linear 6M
layout.
An (Note: Consider the appropriate XML file. All attributes are not required. XML file-
s Different relevant logic/code can be considered.) 2M

activity_main.xml Java code-


<?xml version="1.0" encoding="utf-8"?> 4M
<LinearLayout xmlns: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"
tools:context=".MainActivity">
<TextView
Page No: 32 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hobbies" android:id="@+id/t1"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/c1"
android:text="Swimmning"
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/c2"
android:text="Running "
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/c3"
android:text="Cycling "
/>
<CheckBox android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/c4"
android:text="Reading "
/>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/c5"
android:text="Football "
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Submit"
android:id="@+id/b1"
/>
</LinearLayout>

MainActivity.java

package com.example.checkbox;
import androidx.appcompat.app.AppCompatActivity;
import java.lang.StringBuffer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
Page No: 33 | 34
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.widget.CheckBox;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
Button b1;
CheckBox c1,c2,c3,c4,c5;
String s;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
s ="Your Hobbies are:- ";
b1=(Button) findViewById(R.id.b1);
c1=(CheckBox) findViewById(R.id.c1);
c2=(CheckBox) findViewById(R.id.c2);
c3=(CheckBox) findViewById(R.id.c3);
c4=(CheckBox) findViewById(R.id.c4);
c5=(CheckBox) findViewById(R.id.c5);
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { if(c1.isChecked())
{
s = s + c1.getText()+" ";
Toast.makeText(getApplicationContext(),s,Toast.LENGTH_SHORT).show();
}
if(c2.isChecked())
{
s = s + c2.getText()+" ";
Toast.makeText(getApplicationContext(),s,Toast.LENGTH_SHORT).show();
}
if(c3.isChecked())
{
s = s + c3.getText()+" ";
Toast.makeText(getApplicationContext(),s,Toast.LENGTH_SHORT).show();
}
if(c4.isChecked())
{
s = s + c4.getText()+" ";
Toast.makeText(getApplicationContext(),s,Toast.LENGTH_SHORT).show();
}
if(c5.isChecked())
{
s = s + c5.getText()+" ";
Toast.makeText(getApplicationContext(),s,Toast.LENGTH_SHORT).show();
}
}
});
}
}

Page No: 34 | 34
Question Bank

Subject Mobile Application Dev.

Exam End-Semester Exam

1. Define Android with its key platform components.

The Android platform is composed of several major components that work


together to provide a rich user experience. The major components of the
Android platform are:

 Applications: Android applications are software programs that are


designed to run on the Android platform. These apps can be downloaded
from the Google Play Store or other app marketplaces and can provide a
variety of functionality, from games and entertainment to productivity
tools and social media apps.
 Android Framework: The Android Framework is a set of APIs that allows
developers to create applications that interact with the underlying
hardware and system software. The framework includes libraries for
managing user interfaces, data storage, connectivity, media playback, and
more.
 Android Runtime: The Android Runtime (ART) is the underlying virtual
machine that runs Android applications. ART is designed to be efficient
and optimized for mobile devices, and it uses a Just-In-Time (JIT)
compiler to improve performance.
 Linux Kernel: The Android platform is built on top of the Linux kernel,
which provides low-level hardware abstraction, memory management,
and other core operating system functionality. 
 Libraries: Android includes a variety of libraries that provide additional
functionality to applications. These include libraries for graphics,
multimedia, networking, and more. 
 System UI: The System UI is the user interface that users interact with on
the Android platform. It includes the lock screen, home screen, app
drawer, and notification panel, among other components. 

2. List out any 6 android versions.

Here are six different versions of the Android platform:

 Android 11
 Android 10
 Android 9 (Pie)
 Android 8 (Oreo)
 Android 7 (Nougat)
 Android 6 (Marshmallow)

3. Define OHA.

OHA (Open Handset Alliance) is a consortium of technology companies, led by


Google, that aims to develop open standards for mobile devices and promote the
adoption of the Android platform. The alliance was established in 2007, and its
members include device manufacturers, software companies, and
telecommunications companies.

The primary goal of the OHA is to create a unified platform for mobile devices
that is open, flexible, and scalable. To achieve this, the alliance works to
develop open-source software and standards for the Android operating system.
This enables device manufacturers to customize their devices and create unique
user experiences while maintaining compatibility with the wider Android
ecosystem.

In addition to developing open standards and software, the OHA also works to
promote the Android platform and support its adoption by device manufacturers
and developers. This includes providing resources, tools, and support for
developers to create and distribute Android apps, as well as working to ensure
that the platform remains secure and stable.

Overall, the OHA plays a key role in the development and growth of the
Android platform, and its work has helped to establish Android as one of the
most widely used mobile operating systems in the world.
4. Explain android ecosystem with the help of a diagram.
Android ecosystem refers to the interdependence between the demand and
supply of users, equipment makers, and software developers. To become an
android developer, it is important to understand the android ecosystem and its
interdependencies. Android is a mobile OS that is a modified version of the
Linux kernel also it is open-source software.

In the Android ecosystem this translates to inter-dependence between users,


developers, and equipment makers. One cannot exist without the other:

 Users buy devices and applications


 Equipment makers sell devices, sometimes bundled with applications
 Developers buy devices, then they make and sell applications

Android ecosystem is all about the interdependence between android


developers (Google), Equipment Manufacturers, and users, as this is an
ecosystem one cannot exist without the other. It is created around the google-
play-mobile application market place including Orchestrate (Google) customers
and applications.
5. Describe any 6 advantages of android OS.
 Open Source: Android is an open-source platform, which means that

developers can access the source code and customize it according to their
needs. This makes it more flexible and adaptable to different devices and
user requirements.
 Customization: Android OS allows users to customize their devices by
installing third-party apps, customizing the home screen and lock screen,
and changing the default settings. This means that users have more
control over their devices, which can lead to a more personalized
experience.
 App ecosystem: The Google Play Store has over 3 million apps, which is
more than any other app store. This means that users have access to a
wide range of apps, including games, productivity tools, social media,
and more.
 Multitasking: Android OS allows users to multitask by running multiple
apps at the same time. This means that users can switch between apps
without having to close them and reopen them. 
 Integration: Android OS is designed to work seamlessly with Google
services such as Gmail, Google Maps, and Google Drive. This means that
users can easily access these services from their devices and integrate
them with other apps.
 Hardware options: Android OS is available on a wide range of devices,
from budget smartphones to high-end tablets and smartwatches. This
means that users have a wide range of options to choose from, depending
on their needs and budget.

6. Explain android architecture.

Android architecture contains different number of components to support any


android device needs. Android software contains an open-source Linux Kernel
having collection of number of C/C++ libraries which are exposed through an
application framework services.

Among all the components Linux Kernel provides main functionality of


operating system functions to smartphones and Dalvik Virtual Machine (DVM)
provide platform for running an android application.

1) Linux kernel

It is the heart of android architecture that exists at the root of android


architecture. Linux kernel is responsible for device drivers, power
management, memory management, device management and resource access.

2) Native Libraries

On the top of linux kernel, their are Native libraries such as WebKit, OpenGL,
FreeType, SQLite, Media, C runtime library (libc) etc.
The WebKit library is responsible for browser support, SQLite is for database,
FreeType for font support, Media for playing and recording audio and video
formats.

3) Android Runtime

In android runtime, there are core libraries and DVM (Dalvik Virtual Machine)
which is responsible to run android application. DVM is like JVM but it is
optimized for mobile devices. It consumes less memory and provides fast
performance.

4) Android Framework

On the top of Native libraries and android runtime, there is android framework.
Android framework includes Android API's such as UI (User Interface),
telephony, resources, locations, Content Providers (data) and package managers.
It provides a lot of classes and interfaces for android application development.

5) Applications

On the top of android framework, there are applications. All applications such
as home, contact, settings, games, browsers are using android framework that
uses android runtime and libraries. Android runtime and native libraries are
using linux kernal.

7. Explain how do android app works ?

Android apps are software applications designed to run on mobile devices


running the Android operating system. The working principle of Android apps
involves a combination of the device's hardware and software resources to
create an interactive user experience.

When a user launches an Android app, the app's code is loaded into the device's
memory. The app then interacts with the device's operating system and
hardware resources, such as the processor, memory, storage, camera,
microphone, and other sensors, to perform its intended functions.

The Android operating system provides an abstraction layer that allows apps to
access these hardware resources without knowing the specifics of each device's
hardware. This abstraction layer also helps ensure that apps are compatible with
a wide range of Android devices.

he app's process is managed by the Android system's Activity Manager, which is


responsible for creating and managing activities (user interfaces) within the app.
The Activity Manager communicates with the app's process via inter-process
communication (IPC) mechanisms provided by the Android system.

The app's user interface is created using the Android framework, which provides
a set of pre-built UI components (such as buttons, text fields, and images) that
can be arranged and customized to create a unique user interface for the app.

8. Define JDK and SDK w.r.t android app development.


In Android development, the terms JDK and SDK are often used. JDK stands
for Java Development Kit, while SDK stands for Software Development Kit.

JDK is a set of software development tools that allow developers to create Java
applications. It includes the Java Runtime Environment (JRE), which allows
you to run Java programs, as well as the Java compiler and other development
tools, such as the Java debugger and JavaDoc.

On the other hand, the Android SDK is a collection of software development


tools that are used to develop applications for the Android operating system.
The Android SDK includes a set of development tools, such as the Android
Studio IDE, the Android Debug Bridge (ADB), the Android Emulator, and
various libraries and APIs for developing Android applications.

When developing Android applications using Java, you need to have both the
JDK and the Android SDK installed on your computer. The JDK is required
because Android development is done using the Java programming language.
The Android SDK is required because it contains the necessary tools and
libraries for building Android applications.

In summary, JDK is necessary for developing Java applications, while the


Android SDK is necessary for developing Android applications using Java.

9. Explain dalvik virtual machine with the help of compiling and packaging
process diagram.

The Dalvik Virtual Machine is a key component of the Android operating


system's architecture. It is responsible for executing Android applications (.apk
files) on devices running the Android operating system.
The Dalvik VM is named after a fishing village in Iceland, and was created by
Dan Bornstein, who was working at Google at the time. The Dalvik VM was
specifically designed for mobile devices with limited resources, such as
memory and processing power.
Unlike traditional Java Virtual Machines, the Dalvik VM uses a register-based
architecture instead of a stack-based architecture. This means that it can run
more efficiently on mobile devices with limited resources.

The Dalvik VM uses a Just-In-Time (JIT) compilation technique, which allows


it to compile code as it is being executed, rather than ahead of time. This helps
to reduce the startup time of applications and improve overall performance.

Furthermore, the Dalvik VM uses a technique called "garbage collection" to


manage memory usage. This means that it automatically frees up memory that is
no longer being used by an application, which helps to prevent memory leaks
and other memory-related issues.
10. Explain emulator . How to create a emulator in android studio ?

An emulator in Android Studio is a software program that simulates the


functionality of an Android device on a computer. It allows developers to test
their apps on a virtual Android device without the need for a physical device.

The emulator creates a virtual environment for the Android operating system,
including a virtual display, virtual storage, and virtual sensors such as GPS and
accelerometer. It can run various Android versions, screen sizes, and device
configurations, which allows developers to test their apps on a range of devices.

Android Studio comes with an emulator called Android Virtual Device (AVD),
which can be configured to simulate different device specifications, such as
screen size, resolution, and hardware specifications. Developers can also
customize the emulator's settings, such as the amount of RAM and storage, and
even emulate various network conditions to test their apps under different
network scenarios.

To create a virtual device in Android Studio, follow these steps:

 Open Android Studio and click on the "AVD Manager" icon in the toolbar
or go to "Tools" > "AVD Manager".
 In the AVD Manager window, click on the "Create Virtual Device"
button.
 Select the device definition you want to use from the list of available
options. You can choose from various devices with different screen sizes,
resolutions, and hardware configurations.
 Click on the "Next" button to configure the virtual device.
 Choose the system image you want to use for the virtual device. You can
download system images for different Android versions from the
"Recommended" tab or the "Other Images" tab.
 Click on the "Next" button and give your virtual device a name.
 Customize the advanced settings if needed (such as RAM size, internal
storage, etc.).
 Click on the "Finish" button to create the virtual device.

11. Explain steps to install android studio.

12. List out the development steps of an android app.

13. Explain how to create your first project in android studio.

14. Explain directory structure of an Android studio project.

Android Studio is the official IDE (Integrated Development Environment)


developed by the JetBrains community which is freely provided by Google for
android app development. After completing the setup of Android Architecture,
we can create an android application in the studio. We need to create a new
project for each sample application and we should understand the folder
structure. It looks like this:
The android project contains different types of app modules, source code files,
and resource files. We will explore all the folders and files in the android app.

1. Manifests Folder
2. Java Folder
3. res (Resources) Folder
 Drawable Folder
 Layout Folder
 Mipmap Folder
 Values Folder
4. Gradle Scripts

Manifests Folder
Manifests folder contains AndroidManifest.xml for creating our android
application. This file contains information about our application such as the
Android version, metadata, states package for Kotlin file, and other application
components. It acts as an intermediator between android OS and our
application.

Java folder
The Java folder contains all the java and Kotlin source code (.java) files that we
create during the app development, including other Test files. If we create any
new project using Kotlin, by default the class file MainActivity.kt file will
create automatically under the package name

Resource (res) folder


The resource folder is the most important folder because it contains all the non-
code sources like images, XML layouts, and UI strings for our android
application.

res/drawable folder
It contains the different types of images used for the development of the
application. We need to add all the images in a drawable folder for the
application development.

res/layout folder
The layout folder contains all XML layout files which we used to define the
user interface of our application. It contains the activity_main.xml file.

Gradle Scripts folder


Gradle means automated build system and it contains a number of files that are
used to define a build configuration that can be applied to all modules in our
application. In build.gradle (Project) there are buildscripts and in build.gradle
(Module) plugins and implementations are used to build configurations that can
be applied to all our application modules.
15. Define view with the help of an example.

In Android, a View is a fundamental building block used to create graphical user


interfaces (GUIs) in an app. A View is essentially a rectangle on the screen that
can be used to display text, images, buttons, and other user interface elements.

Each View has its own properties, such as its size, position, background color,
and other visual attributes, and it can also have a set of behaviors that respond to
user input, such as clicking, dragging, or scrolling.

In Android, Views are organized into a hierarchy, where each View can be a
parent to other Views, and this hierarchical structure is called the View
hierarchy. The topmost View in the hierarchy is usually a ViewGroup, which is
a container for other Views.

Some common View classes in Android include TextView (for displaying text),
ImageView (for displaying images), Button (for creating clickable buttons),
EditText (for accepting text input), and ListView (for displaying a scrollable list
of items).

Views can be created programmatically in Java or Kotlin code, or they can be


defined declaratively in XML layout files. Once created, Views can be added to
the View hierarchy, and their properties can be set and updated as needed.
16. Define layout. List out all the layouts used in android app development.

In Android app development, the layout refers to the structure of the user
interface (UI) components that are displayed on the app screen. It defines how
the UI components are arranged, aligned, and positioned within the app's screen.

There are several types of layouts available in Android app development,


including:

 LinearLayout: This layout arranges UI components in a single row or


column.
 RelativeLayout: This layout arranges UI components relative to one
another, based on their position, size, and alignment.

 ConstraintLayout: This layout allows developers to create complex UI


designs by setting constraints between UI components, specifying their
position and size.
 TableLayout: This layout arranges UI components in a grid-like structure,
with rows and columns.
 FrameLayout: This layout is used to display a single UI component on the
app screen. It is often used as a container for fragments.
 GridLayout: This layout arranges UI components in a grid-like structure,
with equal-sized cells.
 CoordinatorLayout: This layout is used to create responsive UI designs
that adapt to different screen sizes and orientations.
 ScrollView: This layout is used to add scrolling functionality to UI
components that exceed the app screen's size.
 CardView: This layout is used to display UI components in a card-like
structure, with rounded corners and drop shadows.
17. List out all types of layouts . Explain any one of them .

LinearLayout is the most basic layout in android studio, that aligns all the
children sequentially either in a horizontal manner or a vertical manner by
specifying the android:orientation attribute. If one
applies android:orientation=”vertical” then elements will be arranged one
after another in a vertical manner and If you
apply android:orientation=”horizontal” then elements will be arranged one
after another in a horizontal manner.

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout
xmlns: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:orientation="vertical"
tools:context=".MainActivity">
</LinearLayout>

Example -:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

xmlns: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:orientation="vertical"

tools:context=".MainActivity">

<!-- Add Button-->

<Button

android:layout_width="match_parent"

android:layout_margin="10dp"

android:layout_height="wrap_content"/>

<!-- Add Button-->

<Button

android:layout_width="match_parent"

android:layout_margin="10dp"

android:layout_height="wrap_content"/>
<!-- Add Button-->

<Button

android:layout_width="match_parent" android:layout_margin="10dp"

android:layout_height="wrap_content"/>

</LinearLayout> Output UI:

18. Write a program to create a layout using table layout.

<TableLayout
android:id="@+id/tableLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:shrinkColumns="*"
android:stretchColumns="*">

<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:text="Name"
android:textStyle="bold"/>

<TextView
android:text="Age"
android:textStyle="bold"/>

<TextView
android:text="Gender"
android:textStyle="bold"/>

</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:text="John"/>

<TextView
android:text="25"/>

<TextView
android:text="Male"/>

</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:text="Jane"/>

<TextView
android:text="30"/>

<TextView
android:text="Female"/>
</TableRow>

</TableLayout>

19. Define frame layout with its attributes. Write a program to insert an image
using frame layout.

In Android app development, a frame layout is a type of layout manager that


allows you to organize views in a single stack, with each view placed on top of
the previous one.

The attributes of a FrameLayout include:

 android:id: Specifies the ID of the frame layout, which can be used to


reference it from code or other resources.
 android:layout_width and android:layout_height: Specifies the width and
height of the frame layout. You can use values such as "match_parent" or
"wrap_content" to set the size of the frame layout.
 android:background: Specifies the background color or drawable for the
frame layout.
 android:padding: Specifies the amount of padding around the content of
the frame layout.
 android:foreground: Specifies the foreground drawable for the frame
layout.
 android:foregroundGravity: Specifies the gravity of the foreground
drawable.
 android:layout_gravity: Specifies the gravity of the frame layout within
its parent layout.

When using a FrameLayout, it's important to keep in mind that views are placed
on top of each other in the order they are added to the layout. This means that
the last view added will be displayed on top of all other views. Additionally,
since there is no concept of positioning within a FrameLayout, you'll need to
use other layout managers such as RelativeLayout or LinearLayout to position
views relative to each other.

20. What do you mean by attribute? How do you set orientation attribute in
linear layout.

In Android, an attribute is a piece of information that is associated with a view.


Attributes determine the appearance and behavior of a view, and they can be set
in XML layout files or programmatically in Java or Kotlin code.

<LinearLayout
xmlns: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:orientation="vertical"
tools:context=".MainActivity">
</LinearLayout>
21. Explain scroll view with the help of a program.
In Android, a ScrollView is a container that allows users to scroll through its
contents when the contents are too large to fit in the visible area. A ScrollView
can contain any type of content, such as text, images, or other views.

When the contents of the ScrollView are larger than the visible area, users can
scroll through the content by dragging their finger up or down the screen. The
ScrollView will automatically adjust the position of the content so that it
remains within the visible area.

<?xml version="1.0" encoding="utf-8"?>


<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is the first TextView" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is the second TextView" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is the third TextView" />

<!-- Add more TextViews as needed -->

</LinearLayout>
</ScrollView>

22. Explain absolute layout with the help of an example.

In Android, Absolute Layout is a type of layout that allows you to specify the
exact position of each UI element (such as buttons, text, images, etc.) using
absolute (x, y) coordinates on the screen. This means that the elements are
placed exactly where you want them, and their positions do not change with
respect to the other elements or the screen size.

Here is an example of how to use Absolute Layout in Android:

First, you need to create a new Android project in Android Studio and open the
main layout file. Then, change the layout type to AbsoluteLayout by adding the
following line of code to the XML file:

<AbsoluteLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
</AbsoluteLayout>
Inside the AbsoluteLayout, you can add UI elements (such as buttons, text,
images, etc.) and specify their exact position on the screen using the
"android:layout_x" and "android:layout_y" attributes. Here is an example:

<Button
android:id="@+id/myButton"
android:text="Click Me!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="100dp"
android:layout_y="200dp" />

23. Write the xml code to demonstrate the use of relative layout.

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/top_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Top Text"
android:textSize="24sp"
android:layout_marginTop="16dp"
android:layout_centerHorizontal="true"/>
<TextView
android:id="@+id/bottom_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bottom Text"
android:textSize="18sp"
android:layout_marginTop="32dp"
android:layout_below="@id/top_text"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>

<Button
android:id="@+id/my_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="My Button"
android:textSize="18sp"
android:layout_below="@id/top_text"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"/>

</RelativeLayout>

24. Explain different types of views.

In Android app development, views are the basic building blocks for creating
user interfaces. Views represent the visual components that users interact with
when they use an Android app. There are several categories of views in Android
app development, each with its own purpose and functionality. Here are some of
the most common categories of views in Android:

 Layout Views: These views are used to define the layout structure of the
user interface. Examples include LinearLayout, RelativeLayout, and
FrameLayout.

 Text Views: These views are used to display text on the screen. Examples
include TextView, EditText, and Button.

 Image Views: These views are used to display images on the screen.
Examples include ImageView and ImageButton.

 List Views: These views are used to display a list of items on the screen,
such as a list of contacts or emails. Examples include ListView and
RecyclerView.

 Input Views: These views are used to accept user input, such as text or
numbers. Examples include EditText and CheckBox.

 Container Views: These views are used to group other views together.
Examples include LinearLayout and FrameLayout.

 Web Views: These views are used to display web pages within an app.
Examples include WebView and Chrome Custom Tabs.

 Media Views: These views are used to play multimedia content such as
videos and audio files. Examples include VideoView and MediaPlayer.
25. Write a program to implement text view in xml and java file.

Xml code -:

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/myTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textSize="24sp"
android:layout_centerInParent="true" />

</RelativeLayout> Java code -:


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

class MainActivity extends AppCompatActivity {

private TextView myTextView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myTextView = findViewById(R.id.myTextView);
}
}

26. How to define a button in xml? Also set a click event to display a toast
message.

27. Define toast in android. Write the correct syntax to define a toast.

In Android, a Toast is a small notification message that pops up on the screen to


display a brief message to the user. It's commonly used to provide simple
feedback to the user, such as a confirmation message after an action has been
performed or an error message if something went wrong.
A Toast typically appears at the bottom of the screen and disappears after a few
seconds. It can contain text or an icon, or both. Here's an example of how to
create a simple Toast in Android using Java:

Toast.makeText(context, "Hello, world!", Toast.LENGTH_SHORT).show();

28. Describe image button in android with the help of a program.

An ImageButton is a type of button in Android that displays an image instead of


text. When the user clicks on the image, it triggers an action just like a regular
button. Here's an example of how to create an ImageButton in Android using
Java:
Xml code -:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">

<ImageButton
android:id="@+id/myImageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher_foreground" />

</LinearLayout>
Java Code -:

import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

private ImageButton myImageButton;

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

myImageButton = findViewById(R.id.myImageButton);
myImageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Perform some action when the image button is clicked
}
});
}
}
29. Explain check box with the help of a program.
In Android, a CheckBox is a UI element that allows the user to toggle between
two states, checked and unchecked. Here's an example of how to create a
CheckBox in Android using Java:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">

<CheckBox
android:id="@+id/myCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Check me!" />

</LinearLayout>
Java code -:
import android.os.Bundle;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {


private CheckBox myCheckBox;

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

myCheckBox = findViewById(R.id.myCheckBox);
myCheckBox.setOnCheckedChangeListener(new
CompoundButton.OnCheckedChangeListener()
{ @Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (isChecked) {
Toast.makeText(MainActivity.this, "Checkbox is checked",
Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, "Checkbox is unchecked",
Toast.LENGTH_SHORT).show();
}
}
});
}
}
30. Write a program to create a progress bar in android app.

Xml code -:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<ProgressBar
android:id="@+id/myProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />

</RelativeLayout>

Java code -:
import android.os.Bundle;
import android.os.Handler;
import android.widget.ProgressBar;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

private ProgressBar myProgressBar;


private int progressStatus = 0;
private Handler handler = new Handler();

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

myProgressBar = findViewById(R.id.myProgressBar);

new Thread(new Runnable() {


public void run() {
while (progressStatus < 100) {
progressStatus += 1;

// Update the progress bar and display the current value in the text
view
handler.post(new Runnable() {
public void run() {
myProgressBar.setProgress(progressStatus);
}
});

try {
// Sleep for 50 milliseconds to simulate a long-running operation
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
}
}
31. Develop an android application for picking time and date in android app.

Xml code - :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">

<TimePicker
android:id="@+id/myTimePicker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp" />

</LinearLayout>

Java code -:

import android.os.Bundle;
import android.widget.TimePicker;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Calendar;

public class MainActivity extends AppCompatActivity {

private TimePicker myTimePicker;


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

myTimePicker = findViewById(R.id.myTimePicker);

// Set the current time as the default value for the time picker
Calendar calendar = Calendar.getInstance();
myTimePicker.setHour(calendar.get(Calendar.HOUR_OF_DAY));
myTimePicker.setMinute(calendar.get(Calendar.MINUTE));

// Set an onTimeChangedListener to respond to changes in the time picker


myTimePicker.setOnTimeChangedListener(new
TimePicker.OnTimeChangedListener() {
@Override
public void onTimeChanged(TimePicker timePicker, int hourOfDay, int
minute) {
// Display a toast message with the selected time value
String selectedTime = hourOfDay + ":" + minute;
Toast.makeText(MainActivity.this, "Selected time: " + selectedTime,
Toast.LENGTH_SHORT).show();
}
});
}
}
32. Define intent. Describe its uses.

In Android, an Intent is a messaging object that is used to request an action from


another component of the Android system, such as an activity, service, or
broadcast receiver. Intents can be used to start new activities, pass data between
activities, start services, and broadcast events. Here are some common uses for
Intent in Android:

 Starting a new activity: You can use an Intent to start a new activity in
your application, or even in another application. This is commonly used
to transition between different screens or sections of an app, or to launch
a third-party app for a specific task.

 Passing data between activities: You can use an Intent to pass data
between activities, such as user input or data retrieved from a web
service. This data can be simple values like strings and integers, or more
complex objects like arrays or custom classes.

 Starting a service: You can use an Intent to start a service in your


application. Services run in the background and can perform long-running
operations, such as downloading data or playing music.

 Broadcasting events: You can use an Intent to broadcast an event to other


components of the Android system, such as a notification that a new data
is available or the battery is low.

// Create an Intent object to start a new activity


Intent intent = new Intent(MainActivity.this, SecondActivity.class);
// Add any extra data to the intent, if necessary
intent.putExtra("key", "value");

// Start the new activity


startActivity(intent);

33. Explain the types of intent with individual example.

In Android, there are two types of Intent: explicit and implicit. Here's an
explanation of each type with a program example:

Explicit Intent: An explicit intent is used to start a specific activity within your
own application. The target activity is identified by its class name.
Here's an example of how to use an explicit Intent to start a new activity:
// Create an explicit intent to start the SecondActivity
Intent intent = new Intent(MainActivity.this, SecondActivity.class);

// Start the SecondActivity


startActivity(intent);

Implicit Intent: An implicit intent is used to start an activity outside of your


own application or to start an activity within your application that is not
explicitly defined. The target activity is identified by an action or a set of data.
Here's an example of how to use an implicit Intent to start the browser
application:
// Create an implicit intent to view a webpage
Uri webpage = Uri.parse("http://www.google.com");
Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
// Verify that the intent will resolve to an activity
if (intent.resolveActivity(getPackageManager()) != null) {
// Start the activity
startActivity(intent);
}

34. Write a program to create a calculator application and display the result on
second activity using explicit intent.

35. Write a program to demonstrate the use of implicit intent.

Refer question no. 34

36. Explain intent filter with the help of a diagram.

In Android, an IntentFilter is a component that is used to declare the types of


intents that an activity, service, or broadcast receiver can handle. By defining an
IntentFilter, you are telling the Android system which types of intents your
component can respond to.

Here's an example of how to use an IntentFilter in Android:


<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
</activity>

37. Explain activity life cycle.

In Android, an activity is referred to as one screen in an application. It is very


similar to a single window of any desktop application. An Android app consists
of one or more screens or activities.
Each activity goes through various stages or a lifecycle and is managed by
activity stacks. So when a new activity starts, the previous one always remains
below it. There are four stages of an activity.
1. If an activity is in the foreground of the screen i.e at the top of the stack, then
it is said to be active or running. This is usually the activity that the user is
currently interacting with.
2. If an activity has lost focus and a non-full-sized or transparent activity has
focused on top of your activity. In such a case either another activity has a
higher position in multi-window mode or the activity itself is not focusable in
the current window mode. Such activity is completely alive.
3. If an activity is completely hidden by another activity, it is stopped or hidden.
It still retains all the information, and as its window is hidden thus it will
often be killed by the system when memory is needed elsewhere.
4. The system can destroy the activity from memory by either asking it to finish
or simply killing its process. When it is displayed again to the user, it must be
completely restarted and restored to its previous state.
For each stage, android provides us with a set of 7 methods that have their own
significance for each stage in the life cycle. The image shows a path of
migration whenever an app switches from one state to another.

1. onCreate()
It is called when the activity is first created. This is where all the static work is
done like creating views, binding data to lists, etc. This method also provides a
Bundle containing its previous frozen state, if there was one.

2. onStart()
It is invoked when the activity is visible to the user. It is followed by
onResume() if the activity is invoked from the background. It is also invoked
after onCreate() when the activity is first started.

3. onRestart()
It is invoked after the activity has been stopped and prior to its starting stage
and thus is always followed by onStart() when any activity is revived from
background to on-screen.

4. onResume()
It is invoked when the activity starts interacting with the user. At this point, the
activity is at the top of the activity stack, with a user interacting with it. Always
followed by onPause() when the activity goes into the background or is closed
by the user.

5. onPause()
It is invoked when an activity is going into the background but has not yet been
killed. It is a counterpart to onResume(). When an activity is launched in front
of another activity, this callback will be invoked on the top activity (currently
on screen). The activity, under the active activity, will not be created until the
active activity’s onPause() returns, so it is recommended that heavy processing
should not be done in this part.

6. onStop()
It is invoked when the activity is not visible to the user. It is followed
by onRestart() when the activity is revoked from the background, followed by
onDestroy() when the activity is closed or finished, and nothing when the
activity remains on the background only. Note that this method may never be
called, in low memory situations where the system does not have enough
memory to keep the activity’s process running after its onPause() method is
called.

7. onDestroy()
The final call received before the activity is destroyed. This can happen either
because the activity is finishing (when finish() is invoked) or because the
system is temporarily destroying this instance of the activity to save space. To
distinguish between these scenarios, check it with isFinishing() method.

38. Explain broadcast with its types.

In Android, a broadcast is a message that is sent by the system or an application


to other applications, notifying them of a certain event or state change.
Broadcasts can be used to trigger actions in other applications or to inform them
of a change in the system state.

There are two types of broadcasts in Android:

System Broadcasts: These are broadcasts that are sent by the system to notify
applications of system-level events, such as the device being restarted or the
battery level changing.
Here are some examples of system broadcasts:

ACTION_BATTERY_CHANGED: This broadcast is sent when the battery


level or charging state changes.
ACTION_BOOT_COMPLETED: This broadcast is sent when the device
finishes booting up.
ACTION_TIMEZONE_CHANGED: This broadcast is sent when the device's
timezone is changed.
Custom Broadcasts: These are broadcasts that are sent by applications to notify
other applications of events that are specific to the application.
// Create an intent to send a custom broadcast
Intent intent = new
Intent("com.example.ACTION_CUSTOM_BROADCAST");
intent.putExtra("message", "Hello, world!");

// Send the broadcast


sendBroadcast(intent);

Other applications can receive this broadcast by registering a BroadcastReceiver


with an IntentFilter that matches the custom action:

// Create a BroadcastReceiver to handle the custom broadcast


private BroadcastReceiver receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// Get the message from the intent
String message = intent.getStringExtra("message");

// Do something with the message


Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
}
};
// Register the BroadcastReceiver
IntentFilter filter = new
IntentFilter("com.example.ACTION_CUSTOM_BROADCAST");
registerReceiver(receiver, filter);

39. Explain content provider with the help of a diagram.

In Android, Content Providers are a very important component that serves the
purpose of a relational database to store the data of applications. The role of the
content provider in the android system is like a central repository in which data
of the applications are stored, and it facilitates other applications to securely
access and modifies that data based on the user requirements. Android system
allows the content provider to store the application data in several ways. Users
can manage to store the application data like images, audio, videos, and
personal contact information by storing them in SQLite Database , in files, or
even on a network. In order to share the data, content providers have certain
permissions that are used to grant or restrict the rights to other applications to
interfere with the data.

Operations in Content Provider


Four fundamental operations are possible in Content Provider
namely Create, Read, Update, and Delete. These operations are often termed
as CRUD operations.
 Create: Operation to create data in a content provider.
 Read: Used to fetch data from a content provider.
 Update: To modify existing data.
 Delete: To remove existing data from the storage.

Creating a Content Provider


Following are the steps which are essential to follow in order to create a
Content Provider:

 Create a class in the same directory where the that MainActivity file resides
and this class must extend the ContentProvider base class.
 To access the content, define a content provider URI address.
 Create a database to store the application data.
 Implement the six abstract methods of ContentProvider class.
 Register the content provider in AndroidManifest.xml file
using <provider> tag.

40. Develop an application with fragments.

41. Define service. What do you mean by started and bound service.

In Android, a Service is a component that runs in the background to perform


long-running operations or to handle asynchronous tasks. A Service can run
even when the application is not visible to the user, and can continue running
even if the user switches to another application.

Here are some characteristics of a Service in Android:

 A Service does not have a user interface.


 A Service runs in the same process as the application by default, but can
run in a separate process if needed.
 A Service can be started by another component (such as an activity) using
the startService method, or it can be bound to by another component
using the bindService method.
 A Service can communicate with other components using various
mechanisms, such as broadcast intents, callbacks, or Messenger objects.

In Android, there are two types of services:

Started Service: A started service is a service that is started using the


startService() method. A started service runs in the background even if the
component that started it is destroyed, and can continue to run even if the device
is restarted. The service must be explicitly stopped using the stopService()
method or by calling stopSelf() from within the service.

Bound Service: A bound service is a service that is bound to by another


component using the bindService() method. A bound service provides a client-
server interface, allowing other components to interact with it by calling
methods on a binder object that the service returns when it is bound. A bound
service is destroyed when all of its clients unbind from it.

42. Explain service life cycle.


Refer book

43. Explain multimedia framework.

The Multimedia Framework in Android is a set of software components that


allows developers to easily integrate multimedia capabilities into their
applications. This framework includes various APIs for playing and recording
audio and video, working with images and video streams, and more.

The Multimedia Framework in Android consists of the following components:

 Media Player API: This API allows developers to play audio and video
files, as well as streaming media. It provides a range of features, such as
playback speed control, volume control, and support for various media
formats.

 Media Recorder API: This API allows developers to record audio and
video, as well as capture images. It provides a range of features, such as
video resolution and bitrate control, and support for various media
formats.

 Camera API: This API provides access to the device's camera, allowing
developers to capture images and video. It provides a range of features,
such as autofocus, zoom, and flash control.

 OpenGL ES: This API provides a way for developers to create and
manipulate 3D graphics on Android devices. It provides a range of
features, such as texture mapping, lighting, and animation.
 OpenMAX AL: This API provides a low-level interface for accessing
hardware acceleration for multimedia tasks. It provides a range of
features, such as audio and video decoding and encoding, and supports
various media formats.

 Android NDK: This is a native development kit that allows developers to


write code in C and C++ for use in Android applications. It provides
access to various multimedia APIs, such as OpenMAX AL and OpenGL
ES, and allows for more efficient processing of multimedia data.

The Multimedia Framework in Android provides developers with a powerful set


of tools for integrating multimedia capabilities into their applications. With
these tools, developers can create rich multimedia experiences for their users,
including video and audio playback, image and video capture, and 3D graphics.

44. Write a program to create a camera app.

public class MainActivity extends AppCompatActivity {


private static final int REQUEST_IMAGE_CAPTURE = 1;
private ImageView mImageView;
private Button mButton;

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

mImageView = findViewById(R.id.image_view);
mButton = findViewById(R.id.button);

mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dispatchTakePictureIntent();
}
});
}

private void dispatchTakePictureIntent() {


Intent takePictureIntent = new
Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent,
REQUEST_IMAGE_CAPTURE);
}
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode ==
RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
mImageView.setImageBitmap(imageBitmap);
}
}
}

45. Write a program to create a sms app.

Xml code -:

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns: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"
tools:context=".MainActivity"
android:orientation="vertical"
>

<TextView
android:layout_gravity="center"
android:textSize="30dp"
android:layout_marginTop="20dp"
android:text="SMS Sending App"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>

<EditText
android:padding="20dp"
android:id="@+id/mobilenumber"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:hint="Enter phone number"
android:layout_width="match_parent"
android:layout_height="wrap_content"></EditText>

<EditText
android:padding="20dp"
android:id="@+id/message"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:hint="Enter your message"
android:layout_width="match_parent"
android:layout_height="wrap_content"></EditText>

<Button
android:layout_margin="20dp"
android:padding="20dp"
android:text="Send SMS"
android:id="@+id/send_btn"
android:textSize="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"></Button>

</LinearLayout>
Java Code -:

package com.example.smsapp;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

Button send_btn;
EditText send_phonenumber;
EditText send_message;
String phoneno;
String mymessage;

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

send_btn = findViewById(R.id.send_btn);
send_message = findViewById(R.id.message);
send_phonenumber = findViewById(R.id.mobilenumber);

send_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
phoneno = send_phonenumber.getText().toString();
mymessage = send_message.getText().toString();
try{
SmsManager smsManager = SmsManager.getDefault();

smsManager.sendTextMessage(phoneno,null,mymessage,null,null);
Toast.makeText(getApplicationContext(),"Message
sent",Toast.LENGTH_LONG).show();
}catch(Exception e){

Toast.makeText(getApplicationContext(),"Failed",Toast.LENGTH_LONG).sho
w();
}
}
});
}
}
Manifest File -:

<uses-permission android:name="android.permission.SEND_SMS"></uses-
permission>

46. Write a simple program to create a simple sql lite database.

public class MyDatabaseHelper extends SQLiteOpenHelper {


private static final String DATABASE_NAME = "mydatabase.db";
private static final int DATABASE_VERSION = 1;

public MyDatabaseHelper(Context context) {


super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
// Create the table
String sql = "CREATE TABLE mytable ("
+ "id INTEGER PRIMARY KEY AUTOINCREMENT,"
+ "name TEXT,"
+ "age INTEGER)";

db.execSQL(sql);
}

@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Upgrade the table if needed
db.execSQL("DROP TABLE IF EXISTS mytable");
onCreate(db);
}
}

In this program, we have defined a MyDatabaseHelper class that extends


SQLiteOpenHelper. This class provides methods to create and upgrade the
database schema.

public class MainActivity extends AppCompatActivity {


private MyDatabaseHelper mDatabaseHelper;

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

mDatabaseHelper = new MyDatabaseHelper(this);

// Insert data into the table


SQLiteDatabase db = mDatabaseHelper.getWritableDatabase();
ContentValues values = new ContentValues();
values.put("name", "John");
values.put("age", 25);
db.insert("mytable", null, values);

// Query the data from the table


Cursor cursor = db.rawQuery("SELECT * FROM mytable", null);
if (cursor.moveToFirst()) {
do {
String name = cursor.getString(cursor.getColumnIndex("name"));
int age = cursor.getInt(cursor.getColumnIndex("age"));
Log.d("MainActivity", "Name: " + name + ", Age: " + age);
} while (cursor.moveToNext());
}
cursor.close();
}
}

47. Write a program to locate user’s current location.

To locate a user's current location in an Android app, we can use the


LocationManager and LocationListener classes provided by the Android
framework. Here is an example program that demonstrates how to do this:

public class MainActivity extends AppCompatActivity implements


LocationListener {
private LocationManager locationManager;
private TextView locationTextView;

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

locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
locationTextView = findViewById(R.id.location_text_view);
}

@Override
protected void onResume() {
super.onResume();
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
0, 0, this);
} else {
ActivityCompat.requestPermissions(this, new
String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
}
}

@Override
protected void onPause() {
super.onPause();
locationManager.removeUpdates(this);
}

@Override
public void onLocationChanged(Location location) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
locationTextView.setText("Latitude: " + latitude + "\nLongitude: " +
longitude);
}

@Override
public void onProviderDisabled(String provider) {
Toast.makeText(this, "GPS disabled", Toast.LENGTH_SHORT).show();
}

@Override
public void onProviderEnabled(String provider) {
Toast.makeText(this, "GPS enabled", Toast.LENGTH_SHORT).show();
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
}

Manifest code -:

<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION" />

48. Explain the steps how to publish an android application on google playstore.
49. List sensors in android and explain any one them .

Android devices are equipped with a variety of sensors that enable various
functionalities in apps. Here are some of the common sensors in Android:

 Accelerometer: Measures acceleration force in three dimensions (x, y, z)


and is commonly used to detect changes in orientation or shake events.
 Gyroscope: Measures angular velocity and provides more precise
orientation data than the accelerometer. It can be used in combination
with the accelerometer to detect more complex movements.
 Magnetometer: Measures the strength and direction of the magnetic field
in three dimensions and is commonly used to determine the device's
orientation with respect to the Earth's magnetic field.
 Proximity Sensor: Measures the distance between the device and an
object in front of it and is commonly used to turn off the screen and
disable touch events when the device is held to the ear during a phone
call.
 Ambient Light Sensor: Measures the ambient light level in the
environment and is commonly used to adjust the screen brightness
automatically.
 Barometer: Measures atmospheric pressure and is commonly used to
determine altitude and provide weather data.
 GPS: Uses signals from GPS satellites to determine the device's location.

One of the most commonly used sensors in Android is the GPS sensor. The GPS
sensor uses signals from GPS satellites to determine the device's location. Here
is an example of how to use the GPS sensor in an Android app:
Code -:
public class MainActivity extends AppCompatActivity implements
LocationListener {
private LocationManager locationManager;
private TextView latitudeTextView, longitudeTextView;

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

locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);

latitudeTextView = findViewById(R.id.latitude_text_view);
longitudeTextView = findViewById(R.id.longitude_text_view);
}

@Override
protected void onResume() {
super.onResume();
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
0, 0, this);
} else {
ActivityCompat.requestPermissions(this, new
String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
}
}

@Override
protected void onPause() {
super.onPause();
locationManager.removeUpdates(this);
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull
String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions,
grantResults);
if (requestCode == 1) {
if (grantResults.length > 0 && grantResults[0] ==
PackageManager.PERMISSION_GRANTED) {
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
0, 0, this);
}
}
}
}
@Override
public void onLocationChanged(Location location) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();

latitudeTextView.setText("Latitude: " + latitude);


longitudeTextView.setText("Longitude: " + longitude);
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}

@Override
public void onProviderEnabled(String provider) {
}

@Override
public void onProviderDisabled(String provider) {
}
}

50. Describe the need of permission in android. Explain with any example or
program.

Permissions in Android are used to protect user privacy and security by


controlling the access that apps have to sensitive data and system resources on
the device. Android requires apps to request permission before accessing certain
features or data, and users can choose to grant or deny these requests.
For example, an app that needs access to the device's camera or microphone
must request the CAMERA and RECORD_AUDIO permissions, respectively.
Without these permissions, the app cannot use these features.

Here's an example of how to request permission to access the camera in an


Android app:

public class MainActivity extends AppCompatActivity {


private static final int REQUEST_CAMERA_PERMISSION = 1;
private Camera camera;

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

if (ContextCompat.checkSelfPermission(this,
Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new
String[]{Manifest.permission.CAMERA},
REQUEST_CAMERA_PERMISSION);
} else {
startCamera();
}
}
private void startCamera() {
try {
camera = Camera.open();
CameraPreview preview = new CameraPreview(this, camera);
FrameLayout previewLayout = findViewById(R.id.preview_layout);
previewLayout.addView(preview);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull
String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions,
grantResults);
if (requestCode == REQUEST_CAMERA_PERMISSION) {
if (grantResults.length > 0 && grantResults[0] ==
PackageManager.PERMISSION_GRANTED) {
startCamera();
} else {
Toast.makeText(this, "Camera permission denied",
Toast.LENGTH_SHORT).show();
}
}
}
@Override
protected void onPause() {
super.onPause();
if (camera != null) {
camera.release();
camera = null;
}
}
}

51. State and elaborate the syntax of required class and methods
for Geocoding.

52. Define activity in android. Explain how to create a new activity and switch
from one activity to another.

In Android, an activity is a component that provides a user interface (UI) for an


app. It represents a single screen with a user interface that the user can interact
with. An app may have multiple activities, each representing a different screen
or workflow.

Activities are a fundamental building block of Android apps, and they are
responsible for managing their own lifecycle, including being created, started,
paused, resumed, stopped, and destroyed. They can also be organized into
backstacks to enable users to navigate between different screens and workflows.

53. Develop this registration form UI. Write only xml code.
Roll N
Exam Seat

COMPUTER GROUP | SEMESTER - VI I DIPLOMA IN ENGINEERING AND TECHNOLOGY

‹,(22617)”
Mobile Application Development (22617)

Practical No. 2: Install and configure java development kit (JDK),


Android studio and android SDK.
I. Practical Significance
Android is based on Linux with a set of native core C/C++ libraries. Android
applications are written in Java. However, they run on Android's own Java Virtual
Machine, called Dalvik Virtual Machine (DVM) (instead of JDK's JVM) which is
optimized to operate on the small and mobile devices. SDK provides a selection of tools
required to build Android apps or to ensure the process goes as smoothly as possible.
Whether creating an app with Java, Kotlin or C#, SDK should run on an Android device
and access unique features of the OS.

II. Relevant Program Outcomes (POs)


PO 1. Basic knowledge
PO 2. Discipline knowledge
PO 7. Ethics

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to know the android operating system installation and configuration steps.
2. Able to install different versions of android operating system using the
knowledge of installation and configuration steps.

IV. Relevant Course Outcome(s)


Configure Android environment and development tools.

V. Practical Outcome (PrOs)


Install and configure java development kit (JDK), android studio and android SDK.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


Step 1 - Setup Java Development Kit (JDK) You can download the latest version of
Java JDK from Oracle's Java site: Java SE Downloads. You will find instructions for
installing JDK in downloaded files, follow the given instructions to install and configure
the setup. Finally, set PATH and JAVA_HOME environment variables to refer to the
directory that contains java and javac, typically java_install_dir/bin and java_install_dir
respectively. If you are running Windows and have installed the JDK in C:\jdk1.6.0_15,
you would have to put the following line in your C:\autoexec.batfile.
set
PATH=C:\jdk1.6.0_15\bin;%PATH%
set JAVA_HOME=C:\jdk1.6.0_15
Step 2 - Setup Android SDK You can download the latest version of Android SDK

Maharashtra State Board of Technical Education 9


Mobile Application Development (22617)

from Android’s official website: http://developer.android.com/sdk/index.html. If you


are installing SDK on Windows machine, then you will find ainstaller_rXX-
windows.exe, so just download and run this exe which will launch Android SDK Tool
Setup wizard to guide you throughout the installation, so just follow the instructions
carefully. Finally, you will have Android SDK Tools installed on your machine. If you
are installing SDK either on Mac OS or Linux, check the instructions provided along
with the downloaded android-sdk_rXX-macosx.zip file for Mac OS and android-
sdk_rXX-linux.tgz file for Linux. This tutorial will consider that you are going to
setup your environment on Windows machine having Windows 7 operating system.
Step 3 - Setup Android Development Tools (ADT) Plugin This step will help you in
setting Android Development Tool plugin for Eclipse. Let's start with launching Eclipse
and then, choose Help > Software Updates > Install New Software. This will display the
following dialogue box.
Step 4 - Create Android Virtual Device to test your Android applications you will
need a virtual Android device. So before we start writing our code, let us create an
Android virtual device. Launch Android AVD Manager using Eclipse menu options
Window > AVD Manager> which will launch Android AVD Manager. Use New button
to create a new Android Virtual Device and enter the following information, before
clicking Create AVD button.

VIII. Resources required (Additional)

Sr. Instrument Specification Quantity Remarks


No. /Object

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must design
more such questions to ensure the achievement of identified CO.
1. List all the steps to install android operating system
2. List various IDEs that can be used to execute android operating system.

(Space for answers)

STEP 1: Download Google Android OS.


STEP 2: Write ISO Image File to CD/DVD or USB Drive.
STEP 3: Boot Your Computer Using CD/DVD or USB Drive.
STEP 4: Install or Test Run Google Android in Your Computer

Ans 2:
Android studio Komodo
Eclipse Cordovo
IntelliJ Idea
Netbeans
Visual Studio

Maharashtra State Board of Technical Education 10


Mobile Application Development (22617)
X. Exercise
Note: Faculty must ensure that every group of students use different input value.
(Use blank space for answers or attach more pages if needed)
1. Differentiate between JVM and DVM.
2. What is IDE? Why Java development toolkit is essential to install an
android operating system?

(Space for answers)

Ans 1:
JVM is the virtual machine that runs java code on different platforms. It acts as an
abstract layer between the program and the platform on which the java code is
running. The portability of Java code is possible only because of the JVM. The javac
compiler converts the source code file(.java file) into an intermediate java
bytecode format which is machine/platform independent.
DVM is a virtual machine to execute Android applications. The Java bytecode(.class
file) generated by javac compiler is converted into Dalvik bytecode to make the
application source files executable on the DVM. Since Android devices have a
definite processing capacity, memory, and battery life, the DVM design principle
aims to optimize itself so Ans it can load fastly and run smoothly even on low
memory/powered devices
Ans 2:
An IDE, or Integrated Development Environment, enables programmers to consolidate
the different aspects of writing a computer program. IDEs increase programmer
productivity by combining common activities of writing software into a single
application: editing source code, building executables, and debugging

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

Maharashtra State Board of Technical Education 11


Mobile Application Development (22617)

List of student Team Members


1.…………………….
2……………………..
3……………………..
4……………………...

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 12


Mobile Application Development (22617)

Practical No. 3: Configure android development tools (ADT) plug-in


and create android virtual device.

I. Practical Significance
Configuration set up steps should be known beforehand as learnt in the practical no.2
Android Development Tools (ADT) is a plugin for the Android studio that is designed
to give you a powerful, integrated environment in which to build Android applications.
ADT extends the capabilities of Android studio to let you quickly set up new Android
projects, create an application UI, add components based on the Android Framework
API, debug your applications using the Android SDK tools, and even export signed (or
unsigned) APKs in order to distribute your application. Developing in Android studio
with ADT is highly recommended and is the fastest way to get started. With the

guided project setup, it provides, as well as tools integration, custom XML editors, and
debug output pane, ADT gives you an incredible boost in developing Android
applications.

II. Relevant Program Outcomes (POs)


PO 1. Basic knowledge
PO 2. Discipline knowledge
PO 7. Ethics

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the foll wing skills
1. Able to install android operating system.

2. Able to differentiate between various versions of android operating system.

IV. Relevant Course Outcome(s)


Configure Android environment and development tools.

V. Practical Outcome (PrOs)


Install and configure java development kit (JDK), android studio and android DK.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


 Setting up Android Development Tools (ADT)
 Get Android Development Tools (ADT) from ADT Bundle

Maharashtra State Board of Technical Education 13


Mobile Application Development (22617)

The ADT Bundle includes everything you need to begin developing apps:
 Android studio + ADT plugin
 Android SDK Tools Android Platform-tools
 The latest Android platform
 The latest Android system image for the emulator

VIII. Resources required (Additional)

Sr. Instrument Specification Quantity Remarks


No. /Object

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must
design more such questions to ensure the achievement of identified CO.
1. List basic requirements for configuring android operating system?
2. Why bytecode cannot run in Android?

(Space for answers)


Ans 1:
 Microsoft Windows 7/8/10 (32-bit or 64-bit)
 3 GB RAM minimum, 8 GB RAM recommended (plus 1 GB for the Android Emulator)
 2 GB of available disk space minimum, 4 GB recommended (500 MB for IDE plus 1.5 GB
for Android SDK and emulator system image)
 1280 x 800 minimum screen resolution.

Ans 2:
Android uses Dalvik Virtual Machine (DVM) which requires a special bytecode. We need
to convert Java class files into Dalvik Executable files using an Android tool called "dx".
In normal circumstances, developers will not be using this tool directly and build tools will
care for the generation of DVM compatible files.
X. Exercise
Note: Faculty must ensure that every group of students use different input value.
(Use blank space for answers or attach more pages if needed)
1. What is a Build Type in Gradle?
2. Explain the build process in Android.

Maharashtra State Board of Technical Education 14


Mobile Application Development (22617)

(Space for answers)


Ans 1:
A build type determines how an app is packaged. By default, the Android plug-in for Gradle
supports two different types of builds: debug and release. Build types define certain properties
that Gradle uses when building and packaging your app, and are typically configured for
different stages of your development lifecycle. For example, the debug build type enables
debug options and signs the APK with the debug key, while the release build type may shrink,
obfuscate, and sign your APK with a release key for distribution.

Ans 2:
The build process for a typical Android app module, as shown in figure 1, follows these
general steps:
1. The compilers convert your source code into DEX (Dalvik Executable) files,
which include the bytecode that runs on Android devices, and everything else into
compiled resources.
2. The APK Packager combines the DEX files and compiled resources into a single
APK. Before your app can be installed and deployed onto an Android device,
however, the APK must be signed.
3. The APK Packager signs your APK using either the debug or release keystore:
a. If you are building a debug version of your app, that is, an app you intend only for
testing and profiling, the packager signs your app with the debug keystore.
Android Studio automatically configures new projects with a debug keystore.
b. If you are building a release version of your app that you intend to release
externally, the packager signs your app with the release keystore. To create a
release keystore, read about signing your app in android studio.
4. Before generating your final APK, the packager uses the zipline tool tool to
optimize your app to use less memory when running on a device.

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

Maharashtra State Board of Technical Education 15


Mobile Application Development (22617)

List of student Team Members


1………………………
2……………………...
3………………………
4………………………

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 16


Mobile Application Development (22617)

Practical No. 4: Develop a program to display Hello World


on screen.

I. Practical Significance
In android studio students must be aware of the directory structure and the control
flow of the program. Program should be either executed on the android mobile phones
or on the suitable emulators. To execute a simple program, like to display Hello World
on screen syntax of writing a program in android is pre-requisite as the programming
language used is JAVA only. The main activity code is a Java file MainActivity.java.
This is the actual application file which ultimately gets converted to a Dalvik executable
and runs your application.

II. Relevant Program Outcomes (POs)


PO 1. Basic knowledge
PO 2. Discipline knowledge
PO 3. Experiments and practice
PO 4. Engineering tools

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the
following skills
1. Able to use basic Java syntax to write a program.
2. Able to analyze the directory structure of android studio.

IV. Relevant Course Outcome(s)


Develop rich user Interfaces by using layouts and controls

V. Practical Outcome (PrOs)


Develop a program to display Hello World on screen.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.
VII. Minimum Theoretical Background
Following is the default code generated by the application wizard for Hello World!
application:
package com.example.helloworld; import android.os.Bundle;
import android.app.Activity; import android.view.Menu; import
android.view.MenuItem;
import android.support.v4.app.NavUtils; public class MainActivity extends
Activity
{
@Override

Maharashtra State Board of Technical Education 17


Mobile Application Development (22617)

public void onCreate(Bundle savedInstanceState)

{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.activity_main,menu);
return true;
}
}
The Manifest File: Whatever component you develop as a part of your application, you
must declare all its components in a manifest file called AndroidManifest.xml which
resides at the root of the application project directory. This file works as an interface
between Android OS and your application, so if you do not declare your component in
this file, then it will not be considered by the OS. The <activity> tag is used to specify
an activity and android:name attribute specifies the fully qualified classname of the
Activity subclass and the android:label attributes specifies a string to useas the label
for the activity. You can specify multiple activities using <activity> tags. The action for
the intent filter is named android.intent.action.MAIN to indicate thatthis activity
serves as the entry point for the application. The category for the intent- filter is named
android.intent.category.LAUNCHER to indicate that the applicationcan be launched
from the device's launcher icon. The @string refers to the strings.xml file explained
below. Hence, @string/app_name refers to the app_name string defined in the
strings.xml file, which is "HelloWorld". Similar way, other strings get populatedin the
application. Following is the list of tags which you will use in your manifest file to
specify different Android application components:
1) <activity>elements for activities
2) <service> elements for services
3) <receiver> elements for broadcast receivers
4) <provider> elements for content providers

VIII. Resources required (Additional)

Sr. No. Instrument Specification Quantity Remarks


/Object
1 Android enabled 2 GB RAM 1 Data cable is
smartphone / Android mandatory for
version supporting emulators
emulator

Maharashtra State Board of Technical Education 18


Mobile Application Development (22617)

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must
design more such questions to ensure the achievement of identified CO.
1. List the files used to write Hello World program.
2. What is an activity in Android programming?

(Space for answers)


Ans 1:
1. The Main Activity File
The main activity code is a Java file MainActivity.java. This is the actual
application file which ultimately gets converted to a Dalvik executable and runs
your application.
2. The Manifest File
Whatever component you develop as a part of your application, you must declare all
its components in a manifest.xml which resides at the root of the application project
directory. This file works as an interface between Android OS and your application,
so if you do not declare your component in this file, then it will not be considered by
the OS.
3. The Strings File
The strings.xml file is located in the res/values folder and it contains all the text that
your application uses. For example, the names of buttons, labels, default text, and
similar types of strings go into this file. This file is responsible for their textual
content.
4. The Layout File
The activity_main.xml is a layout file available in res/layout directory, that is
referenced by your application when building its interface. You will modify this file
very frequently to change the layout of your application.

Ans 2:
An activity is the single screen in android. It is like window or frame of Java. By
the help of activity, you can place all your UI components or widgets in a single screen.
The 7 lifecycle method of Activity describes how activity will behave at different states.
X. Exercise
Note: Faculty must ensure that every group of students use different input value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to display HelloWorld.
2. Write a program to display student name and marks.
(Space for answers)
Ans 1:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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"

Maharashtra State Board of Technical Education 19


Mobile Application Development (22617)
android:background="#FFC107"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#2196F3"
android:text="Hello World!"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

Maharashtra State Board of Technical Education 20


Mobile Application Development (22617)
Ans 2:
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns: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:background="#f6f6f6"
tools:context=".MainActivity">

<TableRow android:background="#98ded9" android:padding="5px">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Students_Information"
android:textColor="#161d6f"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow android:background="#c7ffd8" android:padding="5px" >

<TextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name: Heet ; Marks: 96"
android:textColor="#161d6f"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow android:background="#98ded9" android:padding="5px">

<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name: Meet ; Marks: 97"
android:textColor="#161d6f"
Maharashtra State Board of Technical Education 21
Mobile Application Development (22617)
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow android:background="#c7ffd8" android:padding="5px">

<TextView
android:id="@+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name: Pratik ; Marks: 99"
android:textColor="#161d6f"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow android:background="#98ded9" android:padding="5px">

<TextView
android:id="@+id/text4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name: Shaun ; Marks: 96"
android:textColor="#161d6f"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow android:background="#c7ffd8" android:padding="5px">

<TextView
android:id="@+id/text5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name: Naman ; Marks: 97"
android:textColor="#161d6f"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow android:background="#98ded9" android:padding="5px">


Maharashtra State Board of Technical Education 22
Mobile Application Development (22617)

<TextView
android:id="@+id/text6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name: Hisbaan ; Marks: 92"
android:textColor="#161d6f"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>

Maharashtra State Board of Technical Education 23


Mobile Application Development (22617)

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of student Team Members


1……………………...
2……………………...
3………………………
4………………………

Dated signature of
Marks Obtained
Teacher

Process Product Total


Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 24


Mobile Application Development (22617)

Practical No. 5: Develop a program to implement linear layout


and absolute layout.

I. Practical Significance
To develop and place the android components accurately on the display
screen, android provides various layout managers. Layout managers can be
used on the simple android program too. Various layout managers can be
selected as per the program requirements.

II. Relevant Program Outcomes (POs)


PO 1. Basic knowledge
PO 2. Discipline knowledge
PO 3. Experiments and practice
PO 4. Engineering tools

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to use layout managers to indent the android components on the
display screen.
2. Able to analyze different layout managers and select the appropriate
layout managers as per the program requirements.

IV. Relevant Course Outcome(s)


Develop rich user Interfaces by using layouts and controls

V. Practical Outcome (PrOs)


Develop a program to implement linear layout and absolute layout .

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


Layouts which are subclasses of View Group class and a typical layout defines the visual
structure for an Android user interface and can be created either at run time using
View/View Group objects or you can declare your layout using simple XML file
main_layout.xml which is located in the res/layout folder of your project. layouts
defined in XML file. A layout may contain any type of widgets such as buttons, labels,
textboxes etc. Layout Attributes Each layout has a set of attributes which define the
visual properties of that layout. There are few common attributes among all the layouts
and there are other attributes which are specific to that layout. Types of layouts are
Linear and Absolute layouts.

Maharashtra State Board of Technical Education 25


Mobile Application Development (22617)

Linear Layout: -

VIII. Resources required (Additional)

Sr. Instrument Specification Quantity Remarks


No. /Object
Android enabled 2 GB RAM 1 Data cable is
smartphone / Android mandatory for
1 version supporting emulators
emulator

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must
design more such questions to ensure the achievement of identified CO.
1. Name any three-layout manager?
2. What is Card View?

Ans. 1.
1. Linear Layout
LinearLayout is a view group that aligns all children in a single direction, vertically or
horizontally.
2. Relative Layout
RelativeLayout is a view group that displays child views in relative positions.
3. Table Layout
TableLayout is a view that groups views into rows and columns.

Ans. 2.
CardView is a new widget in Android that can be used to display any sort of data by
providing a rounded corner layout along with a specific elevation. CardView is the view
that can display views on top of each other. The main usage of CardView is that it helps to
give a rich feel and look to the UI design.

Maharashtra State Board of Technical Education 26


Mobile Application Development (22617)
X. Exercise
Note: Faculty must ensure that every group of students use different input value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to place Name, Age and mobile number linearly
(Vertical) on the display screen using Linear layout.
2. Write a program to place Name, Age and mobile number centrally on
the display screen using Absolute layout.

(Space for answers)

Ans 1.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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"
tools:context=".MainActivity">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:layout_editor_absoluteX="199dp"
tools:layout_editor_absoluteY="362dp">

<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#03A9F4"
android:text="Name: Heet"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFC107"
android:text="Age:19"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold" />
Maharashtra State Board of Technical Education 27
Mobile Application Development (22617)

<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#03A9F4"
android:text="Mobile_No:123456789"
android:textColor="#000000"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Maharashtra State Board of Technical Education 28


Mobile Application Development (22617)
Ans 2:
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout xmlns: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:background="#c7ffd8"
tools:context=".MainActivity"
tools:ignore="Deprecated">

<TextView
android:id="@+id/textView"

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="12dp"
android:layout_y="338dp"
android:text="Name: Heet"
android:textColor="#161d6f"
android:textSize="18sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="135dp"
android:layout_y="338dp"
android:text="Age: 18"
android:textColor="#161d6f"
android:textSize="18sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_x="213dp"
android:layout_y="338dp"
android:text="Phone_no: 123456789"
android:textColor="#161d6f"
android:textSize="18sp"
android:textStyle="bold" />

</AbsoluteLayout>

Maharashtra State Board of Technical Education 29


Mobile Application Development (22617)

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

Maharashtra State Board of Technical Education 30


Mobile Application Development (22617)
List of student Team Members

1……………………...
2……………………...
3………………………
4……………………….

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 31


Mobile Application Development (22617)

Practical No. 6: Develop a program to implement frame layout, table


layout and relative layout.

I. Practical Significance
To develop and place the android components accurately on the display
screen, android provides various layout managers. Layout managers can be
used on the simple android program too. Various layout managers can be
selected as per the program requirements.

II. Relevant Program Outcomes (POs)


PO 1. Basic knowledge
PO 2. Discipline knowledge
PO 3. Experiments and practice
PO 4. Engineering tools

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to use layout managers to indent the android components on the
display screen.
2. Able to analyze different layout managers and select the appropriate
layout managers as per the program requirements.

IV. Relevant Course Outcome(s)


Develop rich user Interfaces by using layouts and controls

V. Practical Outcome (PrOs)


Develop a program to implement frame layout, table layout and relative layout .

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


1. Frame Layout:
Frame Layout is designed to block out an area on the screen to display a single item.
Generally, Frame Layout should be used to hold a single child view, because it can be
difficult to organize child views in a way that's scalable to different screen sizes without
the children overlapping each other. You can, however, add multiple children to a Frame
Layout and control their position within the Frame Layout by assigning gravity to each
child, using the android: layout gravity attribute. Child views are drawnin a stack, with
the most recently added child on top. The size of the Frame Layout is the size of its
largest child (plus padding), visible or not (if the Frame Layout's parent permits).

Maharashtra State Board of Technical Education 32


Mobile Application Development (22617)

2. Relative Layout:

A Relative Layout is a very powerful utility for designing a user interface because
it can eliminate nested view groups and keep your layout hierarchy flat, which
improves performance. If you find yourself using several nested Linear Layout
groups, you may be able to replace them with a single Relative Layout.

3. Table Layout:
A Table Layout consists of a number of Table Row objects, each defining a row
(actually, you can have other children, which will be explained below). Table

Layout containers do not display border lines for their rows, columns, or cells.

Each row has zero or more cells; each cell can hold one View object. The table has
as many columns as the row with the most cells. A table can leave cells empty. Cells
can span columns,as they can in HTML. The width of a column is defined bythe row
with the widest cell in that column.

Maharashtra State Board of Technical Education 33


Mobile Application Development (22617)

VIII. Resources required (Additional)

Sr. Instrument Specification Quantity Remarks


No. /Object
Android enabled 2 GB RAM 1 Data cable is
smartphone / Android mandatory for
1 version supporting emulators
emulator

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must
design more such questions to ensure the achievement of identified CO.
1. List different attributes which can be used with any layout managers.
2. What is Grid Layout?

(Space for answers)

Ans 1:
i. android:layout_width:This is the width of the layout.
ii. android:layout_height:This is the height of the layout
iii. android:layout_x:This specifies the x-coordinate of the layout.
iv. android:layout_y:This specifies the y-coordinate of the layout.
v. android:padding: This is the padding of the layout.
vi. android:margin: This is the margin of the layout

Ans 2 :
A layout that places its children in a rectangular grid.
The grid is composed of a set of infinitely thin lines that separate the viewing area into cells.
Throughout the API, grid lines are referenced by grid indices. A grid with N columns has N +
Maharashtra State Board of Technical Education 34
Mobile Application Development (22617)
1 grid indices that run from 0 through N inclusive. Regardless of how GridLayout is configured,
grid index 0 is fixed to the leading edge of the container and grid index N is fixed to its
trailing edge (after padding is taken into account).

X. Exercise
Note: Faculty must ensure that every group of students use different input value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to display 10 students basic information in a table
form using Table layout.
2. Write a program to display all the data types in object-oriented
programming using Frame layout.

(Space for answers)

Ans 1. <?xml version="1.0" encoding="utf-8"?>


<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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"
tools:context=".MainActivity">

<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#31326f"
tools:layout_editor_absoluteX="125dp"
tools:layout_editor_absoluteY="245dp">

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView1"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="center"
android:paddingTop="25dp"
android:paddingBottom="25dp"
android:text="Name"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView2"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_column="2"
Maharashtra State Board of Technical Education 35
Mobile Application Development (22617)
android:layout_gravity="center"
android:paddingTop="25dp"
android:paddingBottom="25dp"
android:text="AGE"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView3"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="center"
android:text="Heet"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView4"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="center"
android:text="19"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView5"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="center"
android:text="Shaun"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView6"
android:layout_width="170dp"
Maharashtra State Board of Technical Education 36
Mobile Application Development (22617)
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="center"
android:text="19"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView7"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="center"
android:text="Pratik"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView8"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="center"
android:text="18"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView9"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="center"
android:text="Gaurang"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView10"
android:layout_width="170dp"
Maharashtra State Board of Technical Education 37
Mobile Application Development (22617)
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="center"
android:text="19"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView11"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="center"
android:text="Meet"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView12"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="center"
android:text="19"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView13"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="center"
android:text="Naman"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView14"
android:layout_width="170dp"
Maharashtra State Board of Technical Education 38
Mobile Application Development (22617)
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="center"
android:text="18"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView15"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="center"
android:text="Divyesh"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView16"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="center"
android:text="19"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView17"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="center"
android:text="Harry"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView18"
android:layout_width="170dp"
Maharashtra State Board of Technical Education 39
Mobile Application Development (22617)
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="center"
android:text="19"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>

<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/textView19"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_gravity="center"
android:text="Ron"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView20"
android:layout_width="170dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_gravity="center"
android:text="18"
android:textColor="#ffc93c"
android:textSize="30sp"
android:textStyle="bold" />
</TableRow>
</TableLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Maharashtra State Board of Technical Education 40


Mobile Application Development (22617)

Ans 2. <?xml version="1.0" encoding="utf-8"?>


<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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"
tools:context=".MainActivity">

<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#02475e"
tools:layout_editor_absoluteX="114dp"
Maharashtra State Board of Technical Education 41
Mobile Application Development (22617)
tools:layout_editor_absoluteY="242dp">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|center"
android:text="LONG"
android:textColor="#fefecc"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:text="BOOLEAN"
android:textColor="#fefecc"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center"
android:text="INT"
android:textColor="#fefecc"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="CHAR"
android:textColor="#fefecc"
android:textSize="30sp"
android:textStyle="bold" />

<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:text="FLOAT"
android:textColor="#fefecc"
android:textSize="30sp"
android:textStyle="bold" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

Maharashtra State Board of Technical Education 42


Mobile Application Development (22617)

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Maharashtra State Board of Technical Education 43
Mobile Application Development (22617)
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of student Team Members


1……………………...
2……………………...
3………………………
4………………………

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 44


Mobile Application Development (22617)

Practical No. 7: Develop a program to implement Text View and Edit Text.

I. Practical Significance
In this practical, UI controls in android like Text view and edit view are
studied. Wherein the UI controls can be developed, used and placed on the
screen using different layout managers as per the problem statement
requirements.

II. Relevant Program Outcomes (POs)


PO 1. Basic knowledge
PO 2. Discipline knowledge
PO 3. Experiments and practice
PO 4. Engineering tools
PO 7. Ethics
PO 10. Life-long learning

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to develop UI controls like Text View and Edit Text.
2. Able to test UI controls like Text View and Edit Text by checking its
placing on the display screen.
3. Able to build UI controls like Text View and Edit Text, once testing is
done and there are no errors.

IV. Relevant Course Outcome(s)


1. Develop rich user Interfaces by using layouts and controls.
2. Use User Interface components for android application development.

V. Practical Outcome (PrOs)


Develop a program to implement Text View and Edit Text.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background

1. Text View:
In Android, Text View displays text to the user and optionally allows them to edit it
programmatically. Text View is a complete text editor, however basic class is
configured to not allow editing but we can edit it. View is the parent class of Text
View Being a subclass of view the text view component can be used in your app’s.
GUI inside a View Group, or as the content view of an activity. We can create a Text
View instance by declaring it inside a layout(XML file) or by instantiating it
programmatically(Java Class).

Maharashtra State Board of Technical Education 45


Mobile Application Development (22617)

2. Edit Text:
In Android, Edit Text is a standard entry widget in android apps. It is an overlay over
Text View that configures itself to be editable. Edit Text is a subclass of Text View
with text editing operations. Often use Edit Text in our applications in order to
provide an input or text field, especially in forms. The simplest example of Edit Text
is Login or Sign-in form. Text Fields in Android Studio are basically Edit Text.
Note: An Edit Text is simply a thin extension of a Text View. An Edit Text
inherits all the properties of a Text View.

VIII. Resources required (Additional)

Sr. Instrument Specification Quantity Remarks


No. /Object
Android enabled 2 GB RAM 1 Data cable is
smartphone / Android mandatory for
1 version supporting emulators
emulator

Maharashtra State Board of Technical Education 46


Mobile Application Development (22617)

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must
design more such questions to ensure the achievement of identified CO.
1. Which of these is not defined as a process state?
a. Non-visible
b. Visible
c. Foreground
d. Background

2. What is the name of the folder that contains the R.java file?
a. src
b. res
c. bin
d. gen

Ans 1 :
Non-visible is not defined as a process state.

Ans 2:
the name of the folder that contains the R.java file is Gen.

X. Exercise
Note: Faculty must ensure that every group of students use different input value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to accept username and password from the end user using Text
View and Edit Text.
2. Write a program to accept and display personal information of the student.

Ans1 <?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns: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"
tools:context=".MainActivity">

<TextView
android:id="@+id/Username"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UserName"
android:layout_marginTop="150dp"
android:layout_marginLeft="40dp" />

<EditText
android:id="@+id/User_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_toRightOf="@+id/Username"

Maharashtra State Board of Technical Education 47


Mobile Application Development (22617)
android:layout_marginTop="150dp"
/>

<TextView
android:id="@+id/Password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Password"
android:layout_marginTop="40dp"
android:layout_below="@+id/Username"
android:layout_marginLeft="40dp"
/>
<EditText
android:id="@+id/Pass_word"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="190dp"
android:layout_toRightOf="@+id/Password"
android:ems="10"
android:inputType="textPassword" />
<Button
android:id="@+id/Submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Submit"
android:layout_marginTop="200dp"
android:layout_below="@+id/Pass_word"
/>
</RelativeLayout>

Maharashtra State Board of Technical Education 48


Mobile Application Development (22617)

Ans 2 <?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns: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"
tools:context=".MainActivity">

<TextView
android:id="@+id/Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:text="Name" />

<EditText
android:id="@+id/editText_Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="60dp"
android:layout_marginRight="@+id/Name"
android:ems="10" />

Maharashtra State Board of Technical Education 49


Mobile Application Development (22617)
<TextView
android:id="@+id/Age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/Name"
android:layout_margin="30dp"
android:text="Age" />

<EditText
android:id="@+id/editText_age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/Name"
android:layout_margin="60dp"
android:layout_marginRight="@+id/Age"
android:ems="10" />

<Button
android:id="@+id/Submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="260dp"
android:text="Submit" />

<TextView
android:id="@+id/Student_Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/Submit"
android:visibility="invisible" />

<TextView
android:id="@+id/Student_age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/Student_Name"
android:visibility="invisible" />
</RelativeLayout>

public class MainActivity extends AppCompatActivity {


EditText Name,Age;
String name,age;
TextView Display_Name,Display_Age;
Button display;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
display=findViewById(R.id.Submit);
display.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
go();
}
});

Maharashtra State Board of Technical Education 50


Mobile Application Development (22617)

}
public void go()
{
Name=findViewById(R.id.editText_Name);
Age=findViewById(R.id.editText_age);

name=Name.getText().toString().trim();
age=Age.getText().toString().trim();

Display_Name=findViewById(R.id.Student_Name);
Display_Age=findViewById(R.id.Student_age);

Display_Name.setVisibility(View.VISIBLE);
Display_Name.setText("Name:"+name);

Display_Age.setVisibility(View.VISIBLE);
Display_Age.setText("Age:"+age);

}
}

Maharashtra State Board of Technical Education 51


Mobile Application Development (22617)

Maharashtra State Board of Technical Education 52


Mobile Application Development (22617)

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of student Team Members


1……………………...
2……………………...
3………………………
4………………………

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 53


Mobile Application Development (22617)

Practical No. 9: Develop a program to implement Button, Image


Button and Toggle Button.

I. Practical Significance
In this practical, UI controls in android like Buttons are studied. There are various
types of buttons like Image button and toggle button which is studied.

II. Relevant Program Outcomes (POs)


PO 1. Basic knowledge
PO 2. Discipline knowledge
PO 3. Experiments and practice
PO 4. Engineering tools
PO 7. Ethics
PO 10. Life-long learning

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to develop UI controls like various types of buttons.
2. Able to use buttons which handles events.
3. Able to build Passive and Active UI controls.

IV. Relevant Course Outcome(s)


1. Develop rich user Interfaces by using layouts and controls.
2. Use User Interface components for android application development.

V. Practical Outcome (PrOs)


Develop a program to implement Button, Image Button and Toggle Button.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


1. Buttons-
In Android, Button represents a push button. The android. widget. Button is subclass
of Text View class and Compound Button is the subclass of Button class. A Push
buttons can be clicked, or pressed by the user to perform an action. There are
different types of buttons used in android such as Compound Button, Toggle Button,
Radio Button. Button is a subclass of Text View class and compound button is the
subclass of Button class. On a button we can perform different actionsor events
likeclick event, pressed event, touch event etc. Android buttons are GUI components
which are sensible to taps (clicks) by the user. When the user taps/clicks on button
in an Android app, the app can respond to the click/tap. Thesebuttons can be divided
into two categories: the first is Buttons with text on, and second is buttons with an
image on.

Maharashtra State Board of Technical Education 54


Mobile Application Development (22617)

2. Types of buttons–
Buttons can be divided into two categories the first is Buttons with text on, and
second is buttons with an image on.

3. Image Button –
A button with images on can contain both an image and a text. Android buttons with
images on are also called Image Button. In Android, Image Button is used to display
a normal button with a custom image in a button. In simple words we can say, Image
Button is a button with an image that can be pressed or clicked by the users. By
default it looks like a normal button with the standard button background that
changes the color during different button states. An image on the surface of a button
is defined within a xml (i.e. layout ) by using src attribute or within java class by
using setImageResource() method. We can also set an image or custom drawable in
the background of the image button . Image Button has all the properties of a normal
button so you can easily perform any event like click or any other event which you
can perform on a normal button.
Note: Standard button background image is displayed in the background of button
whenever you create an image button. To remove that image, you can define your
own background image in xml by using background attribute or in java class by
using setBackground() method.

Maharashtra State Board of Technical Education 55


Mobile Application Development (22617)

4. Toggle Button–
A toggle button allows the user to change a setting between two states. You can
add a basic toggle button to your layout with the Toggle Button object. If you need
to change a button's state yourself, you can use the Compound

Button.setChecked() or Compound Button.toggle() method. To detect when the


user activates the button or switch, create a Compound Button.

OnCheckedChangeListener object and assign it to the button by calling

setOnCheckedChangeListener().
It is beneficial if user have to change the setting between two states. It can be used
to On/Off Sound, Wi-Fi, Bluetooth etc. By default, the android Toggle Button will
be in OFF (Unchecked) state. We can change the default state of Toggle Button by
using android:checked attribute. In case, if we want to change the state of Toggle
Button to ON (Checked), then we need to set android:checked = “true” in our

XML layout file.

Maharashtra State Board of Technical Education 56


Mobile Application Development (22617)

VIII. Resources required (Additional)

Sr. Instrument Specification Quantity Remarks


No. /Object
Android enabled 2 GB RAM 1 Data cable is
smartphone / Android mandatory for
1 version supporting emulators
emulator

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must design
more such questions to ensure the achievement of identified CO.
1. Write a piece of code to set id of the button.
2. How to add image to resources file?
3. List four Android Toggle Button control attributes.

(Space for answers)

Ans 1. <Button android:id="@+id/simpleButton" />

Maharashtra State Board of Technical Education 57


Mobile Application Development (22617)

X. Exercise
Note: Faculty must ensure that every group of students use different
input value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to create a toggle button to display ON / OFF Bluetooth on the
display screen.
2. Write a program to create a simple calculator.

(Space for answers)


Ans 1.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> selector.xml
<RelativeLayout
<?xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.co
<selector
m/apk/res/android"
xmlns:android="http://schemas.android.co
xmlns:app="http://schemas.android.com
m/apk/res/android">
/apk/res-auto"
<item android:state_checked="true"
xmlns:tools="http://schemas.android.co
android:drawable="@drawable/bluetooth_
m/tools"
on"/>
android:layout_width="match_parent"
<item android:state_checked="false"
android:layout_height="match_parent"
android:drawable="@drawable/bluetooth_
tools:context=".MainActivity">
off"/>
<ToggleButton
</selector>
android:id="@+id/toggle"
android:layout_width="185dp"
android:layout_height="wrap_content
Java Code
"
package com.example.togglebutton;
android:layout_centerHorizontal="tru
e"
import
android:layout_marginHorizontal="1
androidx.appcompat.app.AppCompatActiv
30dp"
ity;
android:layout_marginTop="90dp"
android:drawableStart="@drawable/s
import android.os.Bundle;
elector"
import android.view.View;
android:textOff="Bluetooth Off"
import android.widget.ImageView;
android:textOn="Bluetooth ON" />
import android.widget.ToggleButton;
<ImageView
android:layout_width="wrap_content
public class MainActivity extends
"
AppCompatActivity {
android:layout_height="wrap_content
"
ToggleButton toggleButton;
android:id="@+id/imageView"
ImageView imageView;
android:layout_marginTop="100dp"
@Override
android:layout_below="@+id/toggle"
protected void onCreate(Bundle
android:layout_centerHorizontal="tru
savedInstanceState) {
e"
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ma
/> in);
</RelativeLayout>
Maharashtra State Board of Technical Education 58
Mobile Application Development (22617)
toggleButton=findViewById(R.id.tog imageView.setImageDrawabl
gle); e(getResources().getDrawable(R.drawable.
imageView=findViewById(R.id.imag bluetooth_on));
eView); }
else
imageView.setImageDrawable(getRe {
sources().getDrawable(R.drawable.bluetoo imageView.setImageDrawabl
th_off)); e(getResources().getDrawable(R.drawable.
bluetooth_off));
toggleButton.setOnClickListener(new }
View.OnClickListener(){ }
}
@Override );
public void onClick(View v){ }
if (toggleButton.isChecked()) }
{

Maharashtra State Board of Technical Education 59


Mobile Application Development (22617)
Ans 2.
android:layout_width="wrap_conte
XML code
nt"
<?xml version="1.0" encoding="utf-8"?> android:layout_height="wrap_cont
<RelativeLayout ent"
xmlns:android="http://schemas.android.co android:layout_below="@+id/btn_
m/apk/res/android" 6"
xmlns:app="http://schemas.android.com android:layout_toEndOf="@+id/bt
/apk/res-auto" n_5"
xmlns:tools="http://schemas.android.co android:layout_toRightOf="@+id/
m/tools" btn_5"
android:layout_width="match_parent" android:text="9"
android:layout_height="match_parent" android:textSize="18sp" />
tools:context=".MainActivity">
<Button
android:layout_width="match_parent android:id="@+id/btn_8"
" android:layout_width="wrap_conte
android:layout_height="match_parent nt"
" android:layout_height="wrap_cont
android:orientation="horizontal"> ent"
<Button android:layout_below="@+id/btn_
android:id="@+id/btn_1" 5"
android:layout_width="wrap_conte android:layout_toEndOf="@+id/bt
nt" n_7"
android:layout_height="wrap_cont android:layout_toRightOf="@+id/
ent" btn_7"
android:layout_alignParentLeft="tr android:text="8"
ue" android:textSize="18sp" />
android:layout_alignParentStart="t
rue" <Button
android:layout_below="@+id/edTe android:id="@+id/btn_7"
xt1" android:layout_width="wrap_conte
android:layout_marginTop="60dp" nt"
android:layout_height="wrap_cont
android:text="1" ent"
android:textSize="18sp" /> android:layout_alignLeft="@+id/bt
n_4"
<Button android:layout_alignStart="@+id/b
android:id="@+id/btn_0" tn_4"
android:layout_width="wrap_conte android:layout_below="@+id/btn_
nt" 4"
android:layout_height="wrap_cont android:text="7"
ent" android:textSize="18sp" />
android:layout_below="@+id/btn_
8" <Button
android:layout_toEndOf="@+id/bt android:id="@+id/btn_6"
n_7" android:layout_width="wrap_conte
android:layout_toRightOf="@+id/ nt"
btn_7" android:layout_height="wrap_cont
android:text="0" ent"
android:textSize="18sp" /> android:layout_alignBaseline="@+
id/btn_5"
<Button android:layout_alignBottom="@+i
android:id="@+id/btn_9" d/btn_5"
Maharashtra State Board of Technical Education 60
Mobile Application Development (22617)
android:layout_toEndOf="@+id/bt <Button
n_5" android:id="@+id/btn_2"
android:layout_toRightOf="@+id/ android:layout_width="wrap_conte
btn_5" nt"
android:text="6" android:layout_height="wrap_cont
android:textSize="18sp" /> ent"
android:layout_alignBaseline="@+
<Button id/btn_1"
android:id="@+id/btn_5" android:layout_alignBottom="@+i
android:layout_width="wrap_conte d/btn_1"
nt" android:layout_toEndOf="@+id/bt
android:layout_height="wrap_cont n_1"
ent" android:layout_toRightOf="@+id/
android:layout_below="@+id/btn_ btn_1"
2" android:text="2"
android:layout_toEndOf="@+id/bt android:textSize="18sp" />
n_4"
android:layout_toRightOf="@+id/ <Button
btn_4" android:id="@+id/btn_Add"
android:text="5" android:layout_width="wrap_conte
android:textSize="18sp" /> nt"
android:layout_height="wrap_cont
<Button ent"
android:id="@+id/btn_4" android:layout_above="@+id/btn_
android:layout_width="wrap_conte 6"
nt" android:layout_alignParentEnd="tr
android:layout_height="wrap_cont ue"
ent" android:layout_alignParentRight="
android:layout_alignLeft="@+id/bt true"
n_1" android:backgroundTint="@androi
android:layout_alignStart="@+id/b d:color/darker_gray"
tn_1" android:text="+"
android:layout_below="@+id/btn_ android:textColor="@android:colo
1" r/background_light"
android:text="4" android:textSize="18sp" />
android:textSize="18sp" />
<Button
<Button android:id="@+id/btn_Sub"
android:id="@+id/btn_3" android:layout_width="wrap_conte
android:layout_width="wrap_conte nt"
nt" android:layout_height="wrap_cont
android:layout_height="wrap_cont ent"
ent" android:layout_alignLeft="@+id/bt
android:layout_alignBaseline="@+ n_Add"
id/btn_2" android:layout_alignStart="@+id/b
android:layout_alignBottom="@+i tn_Add"
d/btn_2" android:layout_below="@+id/btn_
android:layout_toEndOf="@+id/bt Add"
n_2" android:backgroundTint="@androi
android:layout_toRightOf="@+id/ d:color/darker_gray"
btn_2" android:text="-"
android:text="3" android:textColor="@android:colo
android:textSize="18sp" /> r/background_light"
android:textSize="18sp" />
Maharashtra State Board of Technical Education 61
Mobile Application Development (22617)
ue"
<Button android:layout_marginTop="22dp"
android:id="@+id/btn_Mul" android:ems="10"
android:layout_width="wrap_conte android:inputType="textPersonNa
nt" me"
android:layout_height="wrap_cont android:textAlignment="textEnd"
ent" android:textSize="24sp" />
android:layout_alignLeft="@+id/bt
n_Sub" <Button
android:layout_alignStart="@+id/b android:id="@+id/btn_calc"
tn_Sub" android:layout_width="wrap_conte
android:layout_below="@+id/btn_ nt"
6" android:layout_height="wrap_cont
android:backgroundTint="@androi ent"
d:color/darker_gray" android:layout_below="@+id/btn_
android:text="*" 0"
android:textColor="@android:colo android:layout_toEndOf="@+id/bt
r/background_light" n_0"
android:textSize="18sp" /> android:layout_toRightOf="@+id/
btn_0"
<Button android:backgroundTint="@androi
android:id="@+id/btn_Div" d:color/holo_green_light"
android:layout_width="wrap_conte android:text="="
nt" android:textColor="@android:colo
android:layout_height="wrap_cont r/background_light"
ent" android:textSize="18sp" />
android:layout_alignLeft="@+id/bt
n_Mul" <Button
android:layout_alignStart="@+id/b android:id="@+id/btn_dec"
tn_Mul" android:layout_width="wrap_conte
android:layout_below="@+id/btn_ nt"
9" android:layout_height="wrap_cont
android:backgroundTint="@androi ent"
d:color/darker_gray" android:layout_below="@+id/btn_
android:text="/" 7"
android:textColor="@android:colo android:layout_toLeftOf="@+id/bt
r/background_light" n_8"
android:textSize="18sp" /> android:layout_toStartOf="@+id/bt
n_8"
<EditText android:text="."
android:id="@+id/edText1" android:textSize="18sp" />
android:layout_width="wrap_conte
nt" <Button
android:layout_height="wrap_cont android:id="@+id/btn_clear"
ent" android:layout_width="wrap_conte
android:layout_alignParentEnd="tr nt"
ue" android:layout_height="wrap_cont
android:layout_alignParentLeft="tr ent"
ue" android:layout_alignParentEnd="tr
android:layout_alignParentRight=" ue"
true" android:layout_alignParentRight="
android:layout_alignParentStart="t true"
rue" android:layout_below="@+id/btn_
android:layout_alignParentTop="tr Div"
Maharashtra State Board of Technical Education 62
Mobile Application Development (22617)
android:backgroundTint="@androi findViewById(R.id.btn_5);
d:color/holo_blue_dark" btn_6 = (Button)
findViewById(R.id.btn_6);
android:text="clear" btn_7 = (Button)
android:textColor="@android:colo findViewById(R.id.btn_7);
r/background_light" btn_8 = (Button)
android:textSize="18sp" /> findViewById(R.id.btn_8);
btn_9 = (Button)
findViewById(R.id.btn_9);
btn_Add = (Button)
findViewById(R.id.btn_Add);
</RelativeLayout> btn_Div = (Button)
findViewById(R.id.btn_Div);
btn_Sub = (Button)
Java Code findViewById(R.id.btn_Sub);
btn_Mul = (Button)
findViewById(R.id.btn_Mul);
btn_calc = (Button)
package com.example.exp9_2; findViewById(R.id.btn_calc);
btn_dec = (Button)
import findViewById(R.id.btn_dec);
androidx.appcompat.app.AppCompatActiv btn_clear = (Button)
findViewById(R.id.btn_clear);
ity; ed1 = (EditText)
findViewById(R.id.edText1);
import android.os.Bundle; btn_0.setOnClickListener(new
import android.view.View; View.OnClickListener() {
import android.widget.Button; @Override
import android.widget.EditText; public void onClick(View v) {
ed1.setText(ed1.getText()+"0");
public class MainActivity extends }
AppCompatActivity { });
Button
btn_1,btn_2,btn_3,btn_4,btn_5,btn_6,btn_ btn_1.setOnClickListener(new
7,btn_8,btn_9,btn_0,btn_Add,btn_Sub,btn View.OnClickListener() {
_Mul,btn_Div,btn_calc,btn_dec,btn_clear; @Override
EditText ed1; public void onClick(View v) {
ed1.setText(ed1.getText()+"1");
float Value1, Value2; }
boolean mAddition, mSubtract, });
mMultiplication, mDivision ;
@Override btn_2.setOnClickListener(new
protected void onCreate(Bundle View.OnClickListener() {
savedInstanceState) { @Override
super.onCreate( savedInstanceState ); public void onClick(View v) {
setContentView( ed1.setText(ed1.getText()+"2");
R.layout.activity_main ); }
btn_0 = (Button) });
findViewById(R.id.btn_0);
btn_1 = (Button)
findViewById(R.id.btn_1); btn_3.setOnClickListener(new
btn_2 = (Button) View.OnClickListener() {
findViewById(R.id.btn_2); @Override
btn_3 = (Button) public void onClick(View v) {
findViewById(R.id.btn_3);
btn_4 = (Button) ed1.setText(ed1.getText()+"3");
findViewById(R.id.btn_4);
btn_5 = (Button)

Maharashtra State Board of Technical Education 63


Mobile Application Development (22617)
} public void onClick(View v) {
}); ed1.setText(ed1.getText()+".");
}
btn_4.setOnClickListener(new });
View.OnClickListener() {
@Override btn_Add.setOnClickListener(new
public void onClick(View v) { View.OnClickListener() {
ed1.setText(ed1.getText()+"4"); @Override
} public void onClick(View v) {
});
if (ed1 == null){
btn_5.setOnClickListener(new ed1.setText("");
View.OnClickListener() { }else {
@Override Value1 =
public void onClick(View v) { Float.parseFloat(ed1.getText() + "");
ed1.setText(ed1.getText()+"5"); mAddition = true;
} ed1.setText(null);
}); }
}
btn_6.setOnClickListener(new });
View.OnClickListener() {
@Override btn_Sub.setOnClickListener(new
public void onClick(View v) { View.OnClickListener() {
ed1.setText(ed1.getText()+"6"); @Override
} public void onClick(View v) {
}); Value1 =
Float.parseFloat(ed1.getText() + "");
mSubtract = true ;
btn_7.setOnClickListener(new ed1.setText(null);
View.OnClickListener() { }
@Override });
public void onClick(View v) {
ed1.setText(ed1.getText()+"7"); btn_Mul.setOnClickListener(new
} View.OnClickListener() {
}); @Override
public void onClick(View v) {
btn_8.setOnClickListener(new Value1 =
View.OnClickListener() { Float.parseFloat(ed1.getText() + "");
@Override mMultiplication = true ;
public void onClick(View v) { ed1.setText(null);
ed1.setText(ed1.getText()+"8"); }
} });
});
btn_Div.setOnClickListener(new
btn_9.setOnClickListener(new View.OnClickListener() {
View.OnClickListener() { @Override
@Override public void onClick(View v) {
public void onClick(View v) { Value1 =
ed1.setText(ed1.getText()+"9"); Float.parseFloat(ed1.getText()+"");
} mDivision = true ;
}); ed1.setText(null);
btn_dec.setOnClickListener(new }
View.OnClickListener() { });
@Override

Maharashtra State Board of Technical Education 64


Mobile Application Development (22617)
btn_calc.setOnClickListener(new + "");
View.OnClickListener() { mMultiplication=false;
@Override }
public void onClick(View v) {
Value2 = if (mDivision == true){
Float.parseFloat(ed1.getText() + ""); ed1.setText(Value1 /
Value2+"");
if (mAddition == true){ mDivision=false;
}
ed1.setText(Value1 + Value2 }
+""); });
mAddition=false;
} btn_clear.setOnClickListener(new
View.OnClickListener() {
@Override
if (mSubtract == true){ public void onClick(View v) {
ed1.setText(Value1 - Value2 ed1.setText("");
+""); }
mSubtract=false; });
}
}
if (mMultiplication == true){ }
ed1.setText(Value1 * Value2

Output

Maharashtra State Board of Technical Education 65


Mobile Application Development (22617)

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of student Team Members


1……………………...
2……………………...
3………………………
4………………………

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 66


Mobile Application Development (22617)

Practical No. 10: Develop a program to implement login window


using above UI controls.

I. Practical Significance
In this practical, all the previous UI controls in android like Text View, Edit Text
Buttons which are studied are implemented in this practical. Events are also handled
on the android UI controls used in the practical.

II. Relevant Program Outcomes (POs)


PO 1. Basic knowledge
PO 2. Discipline knowledge PO 4. Engineering tools
PO 7. Ethics
PO 10. Life-long learning

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to use the layout managers.
2. Able to develop android UI controls to create login window without
using databases.

IV. Relevant Course Outcome(s)


1. Develop rich user Interfaces by using layouts and controls.
2. Use User Interface components for android application development.

V. Practical Outcome (PrOs)


Develop a program to implement Button, Image Button and Toggle Button.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


A login application is the screen asking your credentials to login to some
particular application. You might have seen it when logging into facebook,
twitter etc. Define two Text View asking username and password of the user.
The password Text View must have input Type set to password. Its syntax is
given below

Maharashtra State Board of Technical Education 67


Mobile Application Development (22617)

Define a button with login text and set its onClick Property. After that define the

function mentioned in the onClick property in the java file.

Maharashtra State Board of Technical Education 68


Mobile Application Development (22617)

VIII. Resources required (Additional)


Sr. Instrument Specification Quantity Remarks
No. /Object
Android enabled 2 GB RAM 1 Data cable is
smartphone / Android mandatory for
1 version supporting emulators
emulator

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must
design more such questions to ensure the achievement of identified CO.
1. Name the file in which respective XML components can be added.
2. List all the UI components which can be used to develop login window.

(Space for answers)

1. xml file in android. The AndroidManifest. xml file contains information


of your package, including components of the application such as
activities, services, broadcast receivers, content providers etc.

2. . UI components used to develop login window are as follows:


i. TextView.
ii. EditText.
iii. Button.

X. Exercise
Note: Faculty must ensure that every group of students use different
input value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to create a login form for a social networking site.
2. Write a program to create a login form for student registration system

(Space for answers)


An 1. import android.view.View;
package com.example.exp10_1; import android.widget.Button;
import android.widget.EditText;
import import android.widget.Toast;
androidx.appcompat.app.AppCo import
mpatActivity; android.widget.ToggleButton;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
Maharashtra State Board of Technical Education 69
Mobile Application Development (22617)
});
public class MainActivity extends
AppCompatActivity { }
}
EditText username;
String Username; <?xml version="1.0"
Button login; encoding="utf-8"?>
@Override <RelativeLayout
protected void onCreate(Bundle xmlns:android="http://schemas.a
savedInstanceState) { ndroid.com/apk/res/android"

super.onCreate(savedInstanceStat xmlns:app="http://schemas.andro
e); id.com/apk/res-auto"

setContentView(R.layout.activity_ xmlns:tools="http://schemas.andr
main); oid.com/tools"

username=findViewById(R.id.Use android:layout_width="match_pa
rname_ET); rent"

login=findViewById(R.id.Login); android:layout_height="match_p
arent"
login.setOnClickListener(new tools:context=".MainActivity">
View.OnClickListener()
{ <TextView
@Override android:id="@+id/Name"
public void onClick(View
v) { android:layout_width="wrap_con
tent"
Username=username.getText().toS
tring(); android:layout_height="wrap_co
ntent"
Toast.makeText(MainActivity.this android:text="Name"
,"Welcome
"+Username,Toast.LENGTH_SH android:layout_marginTop="40d
ORT).show(); p"
Intent intent=new
Intent(MainActivity.this,Empty_A android:layout_centerHorizontal=
ctivity.class); "true"
// android:textSize="20dp"
intent.putExtra("username",User />
name); <EditText
startActivity(intent);
android:id="@+id/Name_ET"
}
Maharashtra State Board of Technical Education 70
Mobile Application Development (22617)
android:layout_width="match_pa
rent" android:inputType="textPersonN
ame"
android:layout_height="wrap_co
ntent" android:layout_marginTop="20d
android:ems="10" p"

android:inputType="textPersonN android:layout_below="@+id/Age
ame" "
/>
android:layout_below="@+id/Na <TextView
me" android:id="@+id/Branch"

android:layout_marginTop="20d android:layout_width="wrap_con
p" tent"
/>
<TextView android:layout_height="wrap_co
android:id="@+id/Age" ntent"
android:text="Branch"
android:layout_width="wrap_con
tent" android:layout_marginTop="40d
p"
android:layout_height="wrap_co
ntent" android:layout_centerHorizontal=
android:text="Age" "true"

android:layout_marginTop="40d android:layout_below="@+id/Age
p" _ET"
android:textSize="20dp"
android:layout_centerHorizontal=
"true" />
<EditText
android:layout_below="@+id/Na
me_ET" android:id="@+id/Branch_ET"
android:textSize="20dp"
/> android:layout_width="match_pa
<EditText rent"
android:id="@+id/Age_ET"
android:layout_height="wrap_co
android:layout_width="match_pa ntent"
rent" android:ems="10"

android:layout_height="wrap_co android:inputType="textPersonN
ntent" ame"
android:ems="10"
Maharashtra State Board of Technical Education 71
Mobile Application Development (22617)
android:layout_marginTop="20d
p" android:layout_below="@+id/Se
mester"
android:layout_below="@+id/Bra />
nch" <Button
/> android:id="@+id/Login"
<TextView
android:id="@+id/Semester" android:layout_width="wrap_con
tent"
android:layout_width="wrap_con
tent" android:layout_height="wrap_co
ntent"
android:layout_height="wrap_co android:text="Login"
ntent"
android:text="Semester" android:layout_below="@+id/Se
mester_ET"
android:layout_marginTop="40d
p" android:layout_marginTop="40d
p"
android:layout_centerHorizontal=
"true" android:layout_centerHorizontal=
"true"
android:layout_below="@+id/Bra />
nch_ET"
android:textSize="20dp" <TextView
/> android:id="@+id/Login"
<EditText
android:layout_width="wrap_con
android:id="@+id/Semester_ET" tent"

android:layout_width="match_pa android:layout_height="wrap_co
rent" ntent"
android:text="Student Login"
android:layout_height="wrap_co android:textSize="40dp"
ntent"
android:ems="10" android:layout_centerHorizontal=
"true"
android:inputType="textPersonN
ame" android:textColor="@color/teal_2
00"
android:layout_marginTop="20d />
p" </RelativeLayout>

Output:

Maharashtra State Board of Technical Education 72


Mobile Application Development (22617)

Ans 2.
XML file
<?xml version="1.0" android:layout_width="match_pa
encoding="utf-8"?> rent"
<RelativeLayout
xmlns:android="http://schemas.a android:layout_height="match_p
ndroid.com/apk/res/android" arent"
tools:context=".MainActivity">
xmlns:app="http://schemas.andro
id.com/apk/res-auto" <TextView
android:id="@+id/Name"
xmlns:tools="http://schemas.andr
oid.com/tools" android:layout_width="wrap_con
Maharashtra State Board of Technical Education 73
Mobile Application Development (22617)
tent"
android:layout_centerHorizontal=
android:layout_height="wrap_co "true"
ntent"
android:text="Name" android:layout_below="@+id/Na
me_ET"
android:layout_marginTop="40d android:textSize="20dp"
p" />
<EditText
android:layout_centerHorizontal= android:id="@+id/Age_ET"
"true"
android:textSize="20dp" android:layout_width="match_pa
/> rent"
<EditText
android:layout_height="wrap_co
android:id="@+id/Name_ET" ntent"
android:ems="10"
android:layout_width="match_pa
rent" android:inputType="textPersonN
ame"
android:layout_height="wrap_co
ntent" android:layout_marginTop="20d
android:ems="10" p"

android:inputType="textPersonN android:layout_below="@+id/Age
ame" "
/>
android:layout_below="@+id/Na <TextView
me" android:id="@+id/Branch"

android:layout_marginTop="20d android:layout_width="wrap_con
p" tent"
/>
<TextView android:layout_height="wrap_co
android:id="@+id/Age" ntent"
android:text="Branch"
android:layout_width="wrap_con
tent" android:layout_marginTop="40d
p"
android:layout_height="wrap_co
ntent" android:layout_centerHorizontal=
android:text="Age" "true"

android:layout_marginTop="40d android:layout_below="@+id/Age
p" _ET"
Maharashtra State Board of Technical Education 74
Mobile Application Development (22617)
android:textSize="20dp" android:id="@+id/Semester_ET"

/> android:layout_width="match_pa
<EditText rent"

android:id="@+id/Branch_ET" android:layout_height="wrap_co
ntent"
android:layout_width="match_pa android:ems="10"
rent"
android:inputType="textPersonN
android:layout_height="wrap_co ame"
ntent"
android:ems="10" android:layout_marginTop="20d
p"
android:inputType="textPersonN
ame" android:layout_below="@+id/Se
mester"
android:layout_marginTop="20d />
p" <Button
android:id="@+id/Login"
android:layout_below="@+id/Bra
nch" android:layout_width="wrap_con
/> tent"
<TextView
android:id="@+id/Semester" android:layout_height="wrap_co
ntent"
android:layout_width="wrap_con android:text="Login"
tent"
android:layout_below="@+id/Se
android:layout_height="wrap_co mester_ET"
ntent"
android:text="Semester" android:layout_marginTop="40d
p"
android:layout_marginTop="40d
p" android:layout_centerHorizontal=
"true"
android:layout_centerHorizontal= />
"true"
<TextView
android:layout_below="@+id/Bra android:id="@+id/Login"
nch_ET"
android:textSize="20dp" android:layout_width="wrap_con
/> tent"
<EditText
android:layout_height="wrap_co
Maharashtra State Board of Technical Education 75
Mobile Application Development (22617)
ntent" e);
android:text="Student Login"
android:textSize="40dp" setContentView(R.layout.activity_
main);
android:layout_centerHorizontal=
"true" name_et=findViewById(R.id.Nam
e_ET);
android:textColor="@color/teal_2
00" age_et=findViewById(R.id.Age_E
/> T);
</RelativeLayout>
branch_et=findViewById(R.id.Br
Java File: anch_ET);
package com.example.exp10_2;
sem_et=findViewById(R.id.Semes
ter_ET);
import login
androidx.appcompat.app.AppCo =findViewById(R.id.Login);
mpatActivity;
import android.content.Intent; login.setOnClickListener(new
import android.os.Bundle; View.OnClickListener()
import android.view.View; {
import android.widget.Button; @Override
import android.widget.EditText; public void onClick(View
import android.widget.Toast; v) {
import
android.widget.ToggleButton; Username=name_et.getText().toSt
ring();
import android.os.Bundle;
Age=age_et.getText().toString();
public class MainActivity extends
AppCompatActivity { Branch=branch_et.getText().toStr
ing();
EditText
name_et,age_et,branch_et,sem_et Semester=sem_et.getText().toStrin
; g();
String
Username,Age,Branch,Semester; Toast.makeText(MainActivity.this
Button login; ,"Welcome "+Username
,Toast.LENGTH_SHORT).show()
@Override ;
protected void onCreate(Bundle
savedInstanceState) { Toast.makeText(MainActivity.this
,"Age "+Age
super.onCreate(savedInstanceStat ,Toast.LENGTH_SHORT).show()
Maharashtra State Board of Technical Education 76
Mobile Application Development (22617)
; Intent(MainActivity.this,Empty_A
ctivity.class);
Toast.makeText(MainActivity.this //
,"Branch "+Branch intent.putExtra("username",User
,Toast.LENGTH_SHORT).show() name);
; startActivity(intent);

Toast.makeText(MainActivity.this }
,"Semester "+Semester });
,Toast.LENGTH_SHORT).show()
; }
}
Intent intent=new

Output:

Maharashtra State Board of Technical Education 77


Mobile Application Development (22617)

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of student Team Members


1……………………...
2……………………...
3……………………..
4……………………..

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 78


Mobile Application Development (22617)

Practical No. 12: Develop a program to implement Radio Button and


Radio Group.
I. Practical Significance
Radio Buttons are used when we need to select only one item from a list of
presented items. If Radio Buttons are in Radio Group, when one Radio Button
within a group is selected, all others are automatically deselected.

II. Relevant Program Outcomes (POs)


PO 2. Discipline knowledge
PO 3. Experiments and practice
PO 4. Engineering tools

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to develop an application using Radio Button and Radio Group controls.

IV. Relevant Course Outcome(s)


1. Develop rich user Interfaces by using layouts and controls.
2. Use User Interface components for android application development.

V. Practical Outcomes (PrOs)


Use Develop a program to implement Radio Button and Radio Group.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical practices

VII. Minimum Theoretical Background


Radio Button is generally used with Radio Group. Radio Group is a set of radio buttons,
marking one radio button as checked makes all other radio buttons as unchecked. A
radio button consists of two states – checked and unchecked. Clickingan unchecked
button changes its state to “checked” state and “unchecked” for the previously selected
radio button. To toggle a checked state to unchecked state, weneed to choose another
item.
Following are the important attributes related to Radio Group control.
1. android:checkedButton : This is the id of child radio button that should be
checked by default within this radio group.
2. android:orientation : This property on the Radio group defines the orientation to
position its child view consisting of Radio Buttons.
Following are the few methods of radio button:
1. check(id): This sets the selection to the radio button whose identifier is passed in
parameter. -1 is used as the selection identifier to clear the selection.
2. clearCheck() : It clears the selection. When the selection is cleared, no radio
button in this group is selected and getCheckedRadioButtonId() returns null.
3. getCheckedRadioButtonId() : It returns the identifier of the selected radio button
in this group. If its empty selection, the returned value is-1.

Maharashtra State Board of Technical Education 79


Mobile Application Development (22617)

4. setOnCheckedChangeListener() : This registers a callback to be invoked when the


checked radio button changes in this group. We must supply instance of Radio Group.
OnCheckedChangeListener to setOnCheckedChangeListener() method

VIII. Resources used (Additional)

Sr. No. Instrument Specification Quantity Remarks


/Object
Android enabled 2 GB RAM 1 Data cable is
smartphone / Android mandatory for
1 version supporting emulators
emulator

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers mustdesign
more such questions to ensure the achievement of identified CO.
1. Write xml tag to create a Radio button.
2. Write the purpose of Radio Button
3. List different methods of Radio Button

(Space for answers)


1. <RadioButton android:id="@+id/radio_pirates"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/pirates"
android:onClick="onRadioButtonClicked"/>

2. Radio buttons allow the user to select one option from a set. You should use radio
buttons for optional sets that are mutually exclusive if you think that the user needs
to see all available options side-by-side.

Maharashtra State Board of Technical Education 80


Mobile Application Development (22617)

3. Methods of Radio Button:


i. isChecked()
ii. setChecked()
iii. getText()
iv. setText()

X. Exercise
Note: Faculty must ensure that every group of students use different examples.
(Use blank space for answers or attach more pages if needed)
1. Write a program to show the following output. First two radio buttons are without
using radio group and next two radio buttons are using radio group. Note

Maharashtra State Board of Technical Education 81


Mobile Application Development (22617)

(Space for answers)

Ans 1.
XML Code:
android:id="@+id/radioButt
<?xml version="1.0" on1"
encoding="utf-8"?>
<RelativeLayout android:layout_width="wrap
xmlns:android="http://schem _content"
as.android.com/apk/res/andro
id" android:layout_height="wrap
_content"
xmlns:app="http://schemas.a android:text="Radio
ndroid.com/apk/res-auto" Button 1"
xmlns:tools="http://schemas. android:layout_marginTop="
android.com/tools" 80dp"
android:textSize="40dp"
android:layout_width="matc />
h_parent" <RadioButton
android:layout_height="matc android:id="@+id/radioButt
h_parent" on2"
tools:context=".MainActivity android:layout_width="wrap
"> _content"
<TextView android:layout_height="wrap
_content"
android:id="@+id/textv" android:text="Radio
Button 2"
android:layout_width="wrap
_content" android:layout_marginTop="
40dp"
android:layout_height="wrap
_content" android:layout_below="@+id
android:text="Single /radioButton1"
Radio Buttons" android:textSize="40dp"
/>
android:textColor="#000000
" <RadioGroup
android:visibility="visible" android:layout_below="@+id
/radioButton2"
android:layout_centerHorizo
ntal="true" android:layout_width="matc
android:textSize="20dp" h_parent"
android:layout_marginTop=" android:layout_height="200d
20dp" p"
/>
<RadioButton android:layout_marginTop="
Maharashtra State Board of Technical Education 82
Mobile Application Development (22617)
50dp" android:checked="true"

android:id="@+id/radioGrou android:textSize="40dp"
p"> />
</RadioGroup>
<TextView <Button

android:id="@+id/textvr" android:id="@+id/Select"

android:layout_width="wrap android:layout_width="wrap
_content" _content"

android:layout_height="wrap android:layout_height="wrap
_content" _content"
android:text="Radio android:text="Select"
button inside RadioGroup"
android:layout_centerHorizo
android:textSize="20dp" ntal="true"

android:textColor="#000000 android:layout_below="@+id
" /radioGroup"
/>
android:visibility="visible" </RelativeLayout>
Java Code:
android:layout_marginTop="
25dp" package com.example.exp12;
/>
<RadioButton import
androidx.appcompat.app.App
android:id="@+id/male" CompatActivity;

android:layout_width="wrap import android.os.Bundle;


_content" import android.view.View;
import
android:layout_height="wrap android.widget.Button;
_content" import
android:text="Male" android.widget.RadioButton;
import
android:checked="true" android.widget.RadioGroup;
import android.widget.Toast;
android:textSize="40dp"
/>
<RadioButton public class MainActivity
extends AppCompatActivity {
android:id="@+id/female"
RadioButton
android:layout_width="wrap radgender,rad1,rad2;
_content" RadioGroup radSelect;
String gender;
android:layout_height="wrap Button select;
_content"
@Override
android:text="Female" protected void
onCreate(Bundle
Maharashtra State Board of Technical Education 83
Mobile Application Development (22617)
savedInstanceState) { {
int radioID=
super.onCreate(savedInstance radSelect.getCheckedRadioB
State); uttonId();

setContentView(R.layout.acti radgender=findViewById(rad
vity_main); ioID);

radSelect=findViewById(R.id gender=radgender.getText().t
.radioGroup); oString().trim();
if(rad1.isChecked())
rad1=findViewById(R.id.radi {
oButton1); Toast.makeText(this,
"Radio button 1 is selected",
rad2=findViewById(R.id.radi Toast.LENGTH_SHORT).sho
oButton2); w();
}
select=findViewById(R.id.Sel if(rad2.isChecked())
ect); {
Toast.makeText(this,
select.setOnClickListener( "Radio button 2 is selected",
new View.OnClickListener() { Toast.LENGTH_SHORT).sho
public w();
void onClick(View v) { }
Toast.makeText(this,
select(); "Gender :" + gender,
} Toast.LENGTH_SHORT).sho
} w();
); }
} }
public void select()

Maharashtra State Board of Technical Education 84


Mobile Application Development (22617)

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

Maharashtra State Board of Technical Education 85


Mobile Application Development (22617)

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of students/Team Members


1. ……………………...
2. ……………………...
3………………………..
4……………………….

Dated signature
Marks Obtained
of
Teacher
Process Product Total (25)
Related(10) Related(15)

Maharashtra State Board of Technical Education 86


Mobile Application Development (22617)

Practical No. 13: Develop a program to implement Progress Bar

I. Practical Significance
Progress bars are used to show progress of a task. For example, when you are uploading
or downloading something from the internet, it is better to show the progress of
download/upload to the user. In android there is a class called Progress Dialog that
allows you to create progress bar.

II. Relevant Program Outcomes (POs)


PO 2. Discipline knowledge
PO 3. Experiments and practice
PO 4. Engineering tools

III. Competency and Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to develop an application using Progress bar.

IV. Relevant Course Outcome(s)


1. Develop rich user Interfaces by using layouts and controls.
2. Use User Interface components for android application development.

V. Practical Outcomes (PrOs)


Develop a program to implement Progress Bar

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical practices

VII. Minimum Theoretical Background


A user interface element that indicates the progress of an operation. For a visual
overview of the difference between determinate and indeterminate progress modes, see
Progress & activity. Display progress bars to a user in a non-interruptive way.
Progress bar supports two modes to represent progress: determinate and indeterminate.
Indeterminate Progress
Use indeterminate mode for the progress bar when you do not know how long
an operation will take. Indeterminate mode is the default for progress bar and
shows a cyclic animation without a specific amount of progress indicated.
Determinate Progress
Use determinate mode for the progress bar when you want to show that a specific
quantity of progress has occurred. For example, the percent remaining of a file being
retrieved, the amount records in a batch written to database, or the percent remaining
of an audio file that is playing.
Progress Dialog is a class that allows you to create progress bar. In order to
do this, you need to instantiate an object of this class. Its syntax is.
ProgressDialog dialog=new ProgressDialog(this);

Maharashtra State Board of Technical Education 87


Mobile Application Development (22617)

VIII. Resources required (Additional)


Sr. No. Instrument Specification Quantity Remarks
/Object
Android enabled 2 GB RAM 1 Data cable is
smartphone / Android mandatory for
1 version supporting emulators
emulator

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must
design more such questions to ensure the achievement of identified CO.
1. State different methods to update the per entage of progress displayed.
2. Write an xml tag for the determinate progress bar.
3. List different progress bar styles provide by the system.

(Space for answers)

Ans1) You can update the percentage of progress displayed by using the
setProgress(int) method, or by calling incrementProgressBy(int) to increase the
current progress completed by a specified amount. By default, the progress bar is
full when the progress value reaches 100. You can adjust this default by setting the
android:max attribute.

Ans 2) <ProgressBar
android:id="@+id/indeterminateBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
Ans 3) XML attributes
1. android:indeterminateTintMode
2. android:interpolator
3. android:max
4. android:maxHeight
5. android:maxWidth
6. android:min
android:minHeight

Maharashtra State Board of Technical Education 88


Mobile Application Development (22617)
X. Exercise
Note: Below given are few sample questions for reference. Teachers must design
different questions for practice.
(Use blank space for answers or attach more pages if needed)
1. Write a program to display circular progress bar.
2. Write a program to show the following output.

(Space for answers)


Ans 1:
XML CODE
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
JAVA CODE
xmlns:android="http://schemas.android.co
m/apk/res/android" package com.example.progrogress;
xmlns:app="http://schemas.android.com
/apk/res-auto"
xmlns:tools="http://schemas.android.co import
m/tools" androidx.appcompat.app.AppCompatActiv
android:layout_width="match_parent" ity;
android:layout_height="match_parent" import android.app.ProgressDialog;
tools:context=".MainActivity"> import android.os.Bundle;
import android.view.View;
<Button import android.widget.Button;
android:id="@+id/btnDownloadFile" import android.os.Bundle;
android:layout_width="wrap_content
" public class MainActivity extends
android:layout_height="wrap_content AppCompatActivity {
" Button btnDownloadFile;
android:text="Download File" ProgressDialog progressDialog;
android:layout_centerInParent="true" @Override
/> protected void onCreate(Bundle
savedInstanceState) {
</RelativeLayout> super.onCreate(savedInstanceState);
Maharashtra State Board of Technical Education 89
Mobile Application Development (22617)
setContentView(R.layout.activity_ma while (progress <=100){
in); try {
btnDownloadFile = progressDialog.setPro
findViewById(R.id.btnDownloadFile); gress(progress);
btnDownloadFile.setOnClickListener progress++;
(new View.OnClickListener() { Thread.sleep(200);
@Override }catch (Exception ex){
public void onClick(View v) {
progressDialog = new }
ProgressDialog (MainActivity.this); }
progressDialog.setProgressStyle( progressDialog.dismiss();
ProgressDialog.STYLE_HORIZONTAL); }
progressDialog.setTitle("File });
Downloading"); t.start();
progressDialog.setProgress(100) progressDialog.show();
; }
Thread t = new Thread(new });
Runnable() { }
@Override
}
public void run() {
int progress = 0;
OUTPUT

Maharashtra State Board of Technical Education 90


Mobile Application Development (22617)
XI. References / Suggestions for further Reading
1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of students/Team Members


1. ……………………...
2. ……………………...
3……………………….
4……………………….

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 91


Mobile Application Development (22617)

Practical No. 14: Develop a program to implement List View, Grid


View, Image View and Scroll View.

I. Practical Significance
A View occupies a rectangular area on the screen and is responsible for drawing and
event handling. View is the base class for widgets, which are used to create interactive
UI components (buttons, text fields, etc.). The View Group subclass is the base class for
layouts, which are invisible containers that hold other Views (or other ViewGroups) and
define their layout properties.
.
II. Relevant Program Outcomes (POs)
PO 1. Basic knowledge
PO 2- Discipline knowledge
PO 3- Experiments and practice
PO 4- Engineering tools

III. Competency and Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to develop an application using list view
2. Able to develop an application using grid view
3. Able to develop an application using image view
4. Able to develop an application using scroll view

IV. Relevant Course Outcome(s)


1. Develop rich user Interfaces by using layouts and controls.
2. Use User Interface components for android application development.

V. Practical Outcome (PrOs)


Develop a program to implement List View, Grid View, Image View and Scroll View.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical practices

VII. Minimum Theoretical Background


List View
List of scrollable items can be displayed in Android using List View. It helps you to
displaying the data in the form of a scrollable list. Users can then select any list item by
clicking on it. List View is default scrollable so we do not need to use scroll View or
anything else with List View.
List View is widely used in android applications. A very common example of List View
is your phone contact book, where you have a list of your contacts displayed in aList
View and if you click on it then user information is displayed.

Maharashtra State Board of Technical Education 92


Mobile Application Development (22617)

Grid View
In android Grid View is a view group that display items in two dimensional scrolling
grid (rows and columns), the grid items are not necessarily predetermined but they are
automatically inserted to the layout using a List Adapter. Users can then select any
grid item by clicking on it. Grid View is default scrollable so we don’t need to
use Scroll View or anything else with Grid View.

Image View
In Android, Image View class is used to display an image file in application. Image
file is easy to use but hard to master in Android, because of the various screen sizes in
Android devices. An android is enriched with some of the best UI design widgets that
allows us to build good looking and attractive UI based application.

Maharashtra State Board of Technical Education 93


Mobile Application Development (22617)

Scroll Vie
In android scroll View can hold only one direct child. This means that, if you have
complex layout with more views(Buttons, Text Views or any other view) then you

must enclose them inside another standard layout like Table Layout, Relative

Layout or Linear Layout. You can specify layout_width and layout_height to adjust
width and height of screen. You can specify height and width in dp(density pixel) or
px(pixel). Then after enclosing them in a standard layout, enclose the whole layout
in scroll View to make all the element or views scrollable.

VIII. Resources required (Additional)


Sr. Instrument Specification Quantity Remarks
No. /Object
Android enabled 2 GB RAM 1 Data cable is
smartphone / Android mandatory for
1 version supporting emulator emulators

Maharashtra State Board of Technical Education 94


Mobile Application Development (22617)

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must designmore
such questions to ensure the achievement of identified CO.
1. List all attributes of Image View.
2. Write steps to add following string array to grid view.
static final String [] example= new String {“A”, “B”, “C”, “D”, “E”};
3. Describe android:stretchMode attribute of Grid view in detail.
(Space for answers)

Ans 1) All the attributes of Image view are as follows:


1. android:adjustViewBounds
2. android:baseline
3. android:baselineAlignBottom
4. android:cropToPadding
5. android:maxHeight
6. android:maxWidth
7. android:scaleType
8. android:src.
9. android:tint
10.android:tintMode

Ans 2) Steps are as follows:


1. Create a main layout.
2. Paste the following xml and java code.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gridView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="50dp"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >

Maharashtra State Board of Technical Education 95


Mobile Application Development (22617)

</GridView>
ActivityMain.java
import android.app.Activity;

import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.GridView;

import android.widget.TextView;
import android.widget.Toast;
import android.view.View;
import android.widget.AdapterView.OnItemClickListener;
public class MainActivity extends Activity {
GridView grid;
static final String[] letters = new String[] {
"A", "B", "C", "D", "E",
"F", "G", "H", "I", "J",
"K", "L", "M", "N", "O",
"P", "Q", "R", "S", "T",
"U", "V", "W", "X", "Y", "Z"};
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
grid = (GridView) findViewById(R.id.gridView);
ArrayAdapter adapter = new ArrayAdapter(this,
android.R.layout.simple_list_item_1, letters);
grid.setAdapter(adapter);
grid.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id)
{
Mah arashtra State Board of Technical Education 96
Mobile Application Development (22617)

Toast.makeText(getApplicationContext(),
((TextView) v).getText(), Toast.LENGTH_SHORT).show();
}
});

}
}
3. Run the application

Ans 3) android:stretchMode : Defines how columns should stretch to fill the


available empty space, if any. This must be either of the values : none : Stretching
is disabled. spacingWidth : The spacing between each column is stretched.

X. Exercise
(Use blank space provide for answers or attached more pages if needed)
1. Write a program to show the following output. Use appropriate view for the same.

2. Write a program to display an image using Image View and a button


named as “Change Image”. Once you click on button another image

Maharashtra State Board of Technical Education 97


Mobile Application Development (22617)
should get displayed.
3. Write a program to display 15 buttons using grid view.
4. Write a program to display a text view using vertical scroll view.

(Space for answers)

Ans
XML code
import
<?xml version="1.0" encoding="utf-8"?> androidx.appcompat.app.AppCompatActiv
<RelativeLayout ity;
xmlns:android="http://schemas.android.co
m/apk/res/android" import android.os.Bundle;
xmlns:app="http://schemas.android.com
/apk/res-auto" public class MainActivity extends
xmlns:tools="http://schemas.android.co AppCompatActivity {
m/tools"
android:layout_width="match_parent" @Override
android:layout_height="match_parent" protected void onCreate(Bundle
tools:context=".MainActivity"> savedInstanceState) {
super.onCreate(savedInstanceState);
<ListView setContentView(R.layout.activity_ma
android:layout_width="match_parent in);
" }
android:layout_height="match_parent }
"
android:entries="@array/Language_li
st"
/>

</RelativeLayout>
strings.xml
<resources>
<string
name="app_name">Exp14_1</string>
<array name="Language_list">
<item>Android</item>
<item>Java</item>
<item>PHP</item>
<item>Hadoop</item>
<item>Sap</item>
<item>Phython</item>
<item>Ajax</item>
<item>C++</item>
<item>Puby</item>
<item>Rails</item>
</array>
</resources>
Java Code
package com.example.exp14_1;
Maharashtra State Board of Technical Education 98
Mobile Application Development (22617)

Output:

Maharashtra State Board of Technical Education 99


Mobile Application Development (22617)

Ans 2:

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#458"
android:orientation="vertical" >

<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="347dp" />

<Button
android:id="@+id/button1"
android:layout_width="200dp"
android:layout_height="58dp"
android:gravity="center"
android:onClick="mess"
android:text="First Image "
android:textSize="20sp" />
<Button
android:id="@+id/button2"
android:layout_width="218dp"
android:layout_height="63dp"
android:onClick="mess"
android:text="Second Image"
android:textSize="20sp" />
</LinearLayout>
ActivityMain.java
package com.example.exp14_2;
Maharashtra State Board of Technical Education 100
Mobile Application Development (22617)

import
android.os.Bundle;
import
android.view.View;
import
android.widget.ImageView;
import
android.widget.TextView;
import android.app.Activity;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void mess(View v)
{
//initialize image view object
ImageView im=(ImageView)findViewById(R.id.imageView1);
//get clicked button id from view object
switch(v.getId())
{
case R.id.button1:
//if button1 is clicked than set image1
im.setImageResource(R.drawable.myi
mage); break;
case R.id.button2:
//if button2 is clicked than set image2
im.setImageResource(R.drawable.myi

Maharashtra State Board of Technical Education 101


Mobile Application Development (22617)

mage2); break;
}
}
}

Ans 3
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns: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:id="@+id/activity_grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="50dp"
Maharashtra State Board of Technical Education 102
android:listSelector="@color/white"
Mobile Application Development (22617)

android:numColumns="3"
android:padding="20dp"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp"
tools:context=".MainActivity" />
MainActivity.java
package com.example.exp14_3;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.GridView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GridView gridview = (GridView) findViewById(R.id.activity_grid);
gridview.setAdapter(new ButtonAdapter(this));
}
}
ButtonAdapter.java
package com.example.exp14_3;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.Toast;
public class ButtonAdapter extends BaseAdapter
{
private Context mContext;
private int btn_id;
private int total_btns = 15;
Maharashtra State Board of Technical Education 103
Mobile Application Development (22617)

public ButtonAdapter(Context context) {


this.mContext = context;
}
@Override
public int getCount() {
return total_btns;
}
@Override
public Object getItem(int i) {
return null;
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(final int i, View view, ViewGroup viewGroup)
{
Button btn;
if (view == null) {
btn = new Button(mContext);
btn.setText(" Button " + (++btn_id));
btn.setLayoutParams (new ViewGroup.LayoutParams(300,300));
} else {
btn = (Button) view;
}
btn.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Maharashtra State Board of Technical Education 104
Mobile Application Development (22617)

Toast.makeText(v.getContext(), "Button #" +


(i + 1), Toast.LENGTH_SHORT).show();
}
});
return btn;
}
}

4) Ans:
XML File:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Exp_14_3">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="Scroll down"
android:textSize="20dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView2"
android:layout_centerHorizontal="true"
android:layout_marginTop="1000dp"
android:text="You have scrolled too far..."
android:textSize="20dp"/>
</RelativeLayout>
</ScrollView>
Java File:
package com.example.exp14_4;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Maharashtra State Board of Technical Education 105
Practical No. 17: Develop a program to create an activity

I. Practical Significance
An activity represents a single screen with a user interface. For example, an email
application might have one activity that shows a list of new emails, another activity to
compose an email, and one for reading emails.

II. Relevant Program Outcomes (POs)


PO 2- Discipline knowledge
PO 3- Experiments and practice
PO 4- Engineering tools practice
PO 10- Life-long learning

III. Competency and Skills


“Create simple Android applications”
This practical is expected to develop the following skills
1. Create an activity to load all the UI components.

IV. Relevant Course Outcome(s)


1. Develop rich user Interfaces by using layouts and controls.
2. Use User Interface components for android application development.

V. Practical Outcomes (PrOs)


Develop a program to create an activity

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical practices

VII. Minimum Theoretical Background


An activity is the single screen in android. It is like window or frame of Java. By the
help of activity, you can place all your UI components or widgets in a single screen.
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.
As in C, C++ or Java programming language program starts from main () function,
android system initiates its program within an Activity starting with a call on
onCreate() method. Android Activity class is the subclass of ContextThemeWrapper
class. An activity class loads all the UI component using the XML file available in
res/layout folder of the project. Following statement loads UI components from
res/layout/activity_main.xmlfile:
setContentView(R.layout.activity_main);
To write our own activity the new activity must be the derived from
Activity class as given below
public class MainActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/*Code goes here*/
}
/** Called when the activity is about to
become visible. */ @Override
protected void onStart() { super.onStart();
/*Code goes here*/
}
/** Called when the activity has
become visible. */ @Override
protected void onResume() { super.onResume();
/*Code goeshere*/
}
/** Called when another activity is
taking focus. */ @Override
protected void
onPause() {
super.onPause();
/*Code goes here*/
}
/** Called when the activity is no
longer visible. */ @Override
protected void onStop() { super.onStop();
/*Code goes here*/
}
/** Called just before the activity is
destroyed. */ @Override
public void onDestroy() { super.onDestroy();
/*Code goes here*/
}
}

VIII. Resources required (Additional)


Sr. Instrument Specification Quantity Remarks
No. /Object
Android enabled 2 GB RAM 1 Data cable is
1 smartphone / Android mandatory for
versionsupporting emulator emulators

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers mustdesign
more such questions to ensure the achievement of identified CO.
1. Draw the activity life cycle diagram.
2. Give the hierarchy of directory structure where you store activity file.
3. Write difference between onStop() and onDestroy() methods, also
between onPause() and onResume()methods.
(Space for answers)

Ans 1:

Ans 2: All graphics, strings, layouts, and other resource files are stored in the resource
file hierarchy under the res directory.

Ans 3:

Once onStop() is called then onRestart() can be called. onDestroy() is last in the order after
onStop(). onDestory() is called just before an activity is destroyed and after that it is gone it is not
possible to resurrect this.

onPause() is called when the activity is still in the screen, once the method execution is completed
then the activity loses focus. So, onPause() is logically before onStop(). From onPause() it is
possible to call onResume() but it is not possible once onStop() is called.
X. Exercise
(Use blank space provide for answers or attached more pages if needed)
1. Write a program to create a HelloWorld Activity using all lifecycles methods to
display messages using Log.d.

(Space for answers)

Ans1:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/andro
id"
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"
tools:context=".MainActivity">

</androidx.constraintlayout.widget.ConstraintLayout>

Java code
package com.example.exp_17_1;

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

public class MainActivity extends

AppCompatActivity { @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.d("lifecycle","onCreate invoked by meena
talele");
}
@Override
protected void onStart() {
super.onStart();
Log.i("lifecycle","onStart
invoked");
}
@Override
protected void onResume(){
super.onResume();
Log.v("lifecycle","onResume
invoked");
}
@Override
protected void onPause(){
super.onPause();
Log.d("lifecycle","onPause
invoked");
}
@Override
protected void onStop(){
super.onStop();
Log.d("lifecycle","onStop
invoked");
}

@Override
protected void onRestart(){
super.onRestart();
Log.d("lifecycle","onRestart
invoked");
}
@Override
protected void onDestroy(){
super.onDestroy();
Log.d("lifecycle","onDestroy
invoked");
}
//DONE BY Heet Zatakia

Output:

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%
List of student Team Members

1 Gaurang Jadhav
2 Shweta Gupta
3 Heet Zatakia

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(15) Related(10) (25)
Practical No.18: Develop a program to implement new activity using
explicit intent and implicit intent.

I. Practical Significance
Android Intent is the message that is passed between components such as activities,
content providers, broadcast receivers, services etc. It facilitates communication
between different android components

II. Relevant Program Outcomes (POs)


PO 1- Basic knowledge:
PO 2- Discipline knowledge
PO 3- Experiments and practice
PO 4- Engineering tools practice

III. Competency and Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Create an activity using implicit intent.
2. Create an activity and call another activity using explicit intent.

IV. Relevant Course Outcome(s)


1. Develop rich user Interfaces by using layouts and controls.
2. Use User Interface components for android application development.

V. Practical Outcomes (PrOs)


Develop a program to implement new activity using explicit intent and implicit intent.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical practices

VII. Minimum Theoretical Background


Android application components can connect to other Android applications. This
connection is based on a task description represented by an Intent object.
Intents are asynchronous messages which allow application components to request
functionality from other Android components. Intents allow you to interact with
components from the same applications as well as with components contributed by
other applications. For example, an activity can start an external activity for taking a
picture.
Mostly Intents are used for:
a. For Launching an Activity
b. To start a New Service
c. For Broadcasting Messages
d. To Display a list of contacts in List View
Types of intents:
There are two types of intents
a. Implicit Intent
b. Explicit Intent
Implicit Intent:
The implicit intent is the intent where instead of defining the exact components, you
define the action that you want to perform for different activities.
Syntax:
Intent i=new Intent();
i.setAction(Intent.ACTIO
N_SEND);
Explicit Intent:
An explicit intent is an Intent where you explicitly define the component
that needs to be called by the Android System. An explicit intent is one that
you can use to launch a specific app component, such as a particular activity
or service in your app.
Syntax:
Intent I = new
Intent(getApplicationContext(),NextActivity.class);
I.putExtra(“value1” , “This value for Next Activity”);
I.putExtra(“value2” , “This value for Next Activity”);

VIII. Resources required (Additional)


Sr. Instrument Specification Quantity Remarks
No. /Object
Android enabled 2 GB RAM 1 Data cable is
smartphone / Android mandatory for
1 version supporting emulator emulators
Mobile Application Development (22617)

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must designmore such
questions to ensure the achievement of identified CO.
1. List different methods used in Intent.
2. Write an intent to display the phone dialer with the given number filled in.

(Space for answers)


Ans 1:

Ans 2:
Intent i = new Intent(Intent.ACTION_DIAL, u); Context.startActivity(i)

X. Exercise
(Solve any one of the following. Use blank space provide for answers or attached more pages if
needed)
1. Write a program to create a text field and a button “Navigate”. Whenyou enter
“www.google.com” and press navigate button it should open google page.
2. Write a program to create button “Start Dialer”. When u click on this button it
should open the phone dialer.
3. Write a program to create two screens. First screen will take one numberinput from
user. After click on Factorial button, second screen will openand it should display
factorial of the same number. Also specify which type of intent you will use in this
case.

(Space for answers)

Maharashtra State Board of Technical Education 10


Mobile Application Development (22617)
Java Code:
package com.example.exp18_1;
import androidx.appcompat.app.AppCompatActivity; import
android.content.Intent;
import android.net.Uri;
import android.os.Bundle; import
android.view.View; import
android.widget.Button; import
android.widget.EditText;

public class MainActivity extends AppCompatActivity {


EditText editText;
Button btnNavigate; String
text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

btnNavigate=findViewById(R.id.btnNavigate);
btnNavigate.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
editText=findViewById(R.id.edittext);
text=editText.getText().toString().trim();
if(text.equals("www.youtube.com"))
{
go();

}
}
});
}
public void go()
{
Uri uri=Uri.parse("https://www.youtube.com"); Intent
intent=new Intent(Intent.ACTION_VIEW,uri);
startActivity(intent);
}
}

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns: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"
tools:context=".MainActivity">

<EditText android:id="@+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
Maharashtra State Board of Technical Education 11
Mobile Application Development (22617)
android:hint="Enter URL"
/>
<Button
android:id="@+id/btnNavigate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Navigate"
android:layout_below="@+id/edittext"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
/>
</RelativeLayout>

Output:

Ans 2:

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns: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"
tools:context=".MainActivity">
Maharashtra State Board of Technical Education 12
Mobile Application Development (22617)

<Button
android:id="@+id/btnOpenDialer" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Open Dialer"
android:layout_centerInParent="true"
/>

</RelativeLayout>

Java

package com.example.exp18_2;

import androidx.appcompat.app.AppCompatActivity; import android.content.Intent;


import android.view.View;
import android.widget.Button; import android.os.Bundle;

public class MainActivity extends AppCompatActivity { Button btnOenDialer;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
btnOenDialer=findViewById(R.id.btnOpenDialer); btnOenDialer.setOnClickListener(new
View.OnClickListener() {

@Override

public void onClick(View v) { Intent intent=new

Intent((Intent.ACTION_DIAL));
startActivity(intent);

}
);
}
}

Maharashtra State Board of Technical Education 13


Mobile Application Development (22617)

Ans 3) activity_main.xml
<xml version=”1.0” encoding=”utf-8”?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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:id=”@+id/relativeLayout”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
tools:context=”.MainActivity”>
<EditText
android:id=”@+id/editText”
android:layout_width=”315dp”
android:layout_height=”53dp”
android:layout_centerHorizontal=”true”
android:layout_centerVertical=”true”
android:fontFamily=”@font/poppins_medium”
android:hint=”Enter a number”
android:inputType=”number”
android:textSize=”20sp”
app:layout_constraintBottom_toBottomOf=”parent”
app:layout_constraintLeft_toLeftOf=”parent”
app:layout_constraintRight_toRightOf=”parent”
app:layout_constraintTop_toTopOf=”parent”
app:layout_constraintVertical_bias=”0.371”/>

Maharashtra State Board of Technical Education 14


Mobile Application Development (22617)
<Button
android:id=”@+id/btnFact”
android:layout_width=”195dp”
android:layout_height=”43dp”
android:layout_marginTop=”84dp”
android:fontFamily=”@font/poppins_medium”
android:text=”Factorial”
app:layout_constraintLeft_toLeftOf=”parent”
app:layout_constraintRight_toRightOf=”parent”
app:layout_constraintTop_toBottomOf=”@+id/editText”/>
</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java

package com.example.exp18_2;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class MainActivity extends AppCompatActivity
{EditText editText;
Button btnFact;
int fact = 1;
int num=0;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
editText = findViewById(R.id.editText);
btnFact = findViewById(R.id.btnFact);
btnFact.setOnClickListener(new View.OnClickListener()
{@Override
public void onClick(View v)
{go();
}
});
}
public void go(){
num = Integer.parseInt(editText.getText().toString().trim());
for(int i = 1; i <= num; i++){
fact = fact * i;
}
navigate();
}
public void navigate(){
Intent intent = new Intent(MainActivity.this,EmptyActivity.class);
intent.putExtra(“Fact”,fact);
intent.putExtra(“Num”,num);
startActivity(intent);
}
}

Maharashtra State Board of Technical Education 15


Mobile Application Development (22617)
activity_empty.xml

<?xml version=”1.0” encoding=”utf-8”?>


<RelativeLayout xmlns: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”
tools:context=”.EmptyActivity”>
<TextView
android:id=”@+id/textview1”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_centerHorizontal=”true”
android:layout_marginTop=”250dp”
android:fontFamily=”@font/poppins_medium”
android:text=””
android:textColor=”#FFFFFF”
android:textSize=”24sp”/>
<TextView
android:id=”@+id/textview2”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_below=”@+id/textview1”
android:layout_centerHorizontal=”true”
android:layout_marginTop=”20dp”
android:fontFamily=”@font/poppins_medium”
android:text=””
android:textColor=”#FFFFFF”
android:textSize=”24sp” />
</RelativeLayout>

EmptyActivity.java

package com.example.exp18_2;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;
public class EmptyActivity extends AppCompatActivity
{TextView textView1,textView2;
int num,fact;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_empty);
Intent intent = getIntent();
num = intent.getIntExtra(“Num”,0);
fact = intent.getIntExtra(“Fact”,0);
textView1 = findViewById(R.id.textview1);
textView2 = findViewById(R.id.textview2);
textView1.setText(“Number = “+ num);
textView2.setText(“Factorial = “+ fact);
}
Maharashtra State Board of Technical Education 136
Mobile Application Development (22617)
}

I. References / Suggestions for furtherReading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

II. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

Maharashtra State Board of Technical Education 137


Mobile Application Development (22617)

List of student Team Members

4 Gaurang Jadhav
5 Shweta Gupta
6 Heet Zatakia

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(15) Related(10) (25)

Maharashtra State Board of Technical Education 138


Mobile Application Development (22617)

Practical No. 21: Develop a program to implement broadcast receiver

I. Practical Significance
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.

II. Relevant Program Outcomes (POs)


PO1- Basic knowledge
PO2- Discipline knowledge
PO3- Experiments and practice
PO4- Engineering tools

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to Create the Broadcast Receiver.
2. Able to Register Broadcast Receiver.

IV. Relevant Course Outcome(s)


1. Interpret features of Android operating system.
2. Configure Android environment and development tools.
3. Develop rich user Interfaces by using layouts and controls.

V. Practical Outcome (PrOs)


Develop a program to implement broadcast receiver.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


Creating the Broadcast Receiver:
A broadcast receiver is implemented as a subclass of Broadcast Receiver class and
overriding the onReceive() method where each message is received as an Intent object
parameter.
Registering Broadcast Receiver:
An application listens for specific broadcast intents by registering a broadcast receiver
in AndroidManifest.xml file. Consider we are going to register MyReceiver for system
generated event ACTION_BOOT_COMPLETED which is fired by the system once
the Android system has completed the boot process.

Maharashtra State Board of Technical Education 139


Mobile Application Development (22617)

VIII. Resources required (Additional)


Sr. Instrument Specification Quantity Remarks
No. /Object
Android enabled 2 GB RAM 1 Data cable is
1 smartphone / Android version mandatory for
supporting emulator emulators

IX. Practical related Questions


Note:Belowgivenarefewsamplequestionsforreference.Teachersmust
design more such questions to ensure the achievement of identified CO.
1. Differentiated between Activity Intent and Broadcasting Intent.
2. Draw Broadcast Receivers Lifecycle.
3. List the System Events related to Broadcast Receivers.

(Space for answers)

Ans 1) Broadcasting Intents are different from the Intents used to start an Activity or a Service
(discussed in previous Android Tutorials). The intent used to start an Activity makes
changes to an operation the user is interacting with, so the user is aware of the process.
However, in case of broadcasting intent, the operation runs completely in the background,
and is therefore invisible to the user.

Maharashtra State Board of Technical Education 140


Mobile Application Development (22617)

Ans 2) Broadcast Receivers Lifecycle

Ans 3) System Events related to Broadcast Receivers are as follows:


1. android.intent.action.BATTERY_CHANGED
2. android.intent.action.BATTERY_LOW
3. android.intent.action.BATTERY_OKAY
4. android.intent.action.BOOT_COMPLETED
5. android.intent.action.BUG_REPORT
6. android.intent.action.CALL
7. android.intent.action.CALL_BUTTON
X. Exercise
Note: Faculty must ensure that every group of students use different input value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to demonstrate all the system broadcast messages.

(Space for answers)

ActivityMain.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayoutxmlns:android="http://schemas.android.com/a
pk/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"
tools:context=".MainActivity">

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="97dp"
android:layout_marginTop="341dp"
android:text="Broadcasting button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

Maharashtra State Board of Technical Education 141


Mobile Application Development (22617)
MainActivity.java

package com.example.exp21;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity


{Button button;
MyReceivermyReceiver = new MyReceiver();
IntentFilter filter = new IntentFilter();
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = findViewById(R.id.button);
filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{ MainActivity.this.registerReceiver(myReceiver,filter);
}
});
}

@Override
protected void onDestroy()
{ super.onDestroy();
MainActivity.this.
unregisterReceiver(myReceiver);
}
}

MyReceiver.java
package com.example.exp21;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class MyReceiver extends BroadcastReceiver


{public MyReceiver(){
super();
}

@Override
public void onReceive(Context context, Intent intent)
{String intentAction = intent.getAction();
if(intentAction != null){
String toastMessage = "unknown intent action";
Maharashtra State Board of Technical Education 142
Mobile Application Development (22617)
switch(intentAction){
case Intent.ACTION_AIRPLANE_MODE_CHANGED:
boolean status = intent.getBooleanExtra("state",true);
if(status){
toastMessage = "Airoplane Mode turned on";
}else {
toastMessage = "Airoplane Mode turned off";
}
break;
}
Toast.makeText(context,toastMessage,Toast.LENGTH_SHORT).show();
}
}

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.broadcast_messages">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Exp21">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
<receiver android:name=".MyReceiver"
android:exported="false">
</receiver>

</application>

</manifest>

Maharashtra State Board of Technical Education 143


Mobile Application Development (22617)

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme


Performance indicators Weightage
Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of student Team Members

1 Gaurang Jadhav
2 Shweta Gupta
3 Heet Zatakia

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 144


Mobile Application Development (22617)

Practical No. 22: Develop a program to implement sensors.

I. Practical Significance
Most of the android devices have built-in sensors that measure motion, orientation,
and various environmental condition. Android allows us to get the raw data from these
sensors and use it in our application.

II. Relevant Program Outcomes (POs)


PO2- Discipline knowledge
PO3- Experiments and practice
PO4- Engineering tools
PO5- The engineer and society
PO7- Ethics

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to get a list of sensors supported by thedevice.
2. Able to demonstrate the use of Sensor Manager class.

IV. Relevant Course Outcome(s)


1. Interpret features of Android operating system.
2. Configure Android environment and development tools.

V. Practical Outcome (PrOs)


Develop a program to implement sensors.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


The android platform supports three broad categories of sensors. Motion Sensors,
Environmental sensors, Position sensors. Some of the sensors are hardware based and
some are software-based sensors. Whatever the sensor is, android allows us to get the
raw data from these sensors and use it in our application. For this, android provides us
with some classes. Android provides Sensor Manager and Sensor classes to use the
sensors in our application. In order to use sensors, first thing you need to do is to
instantiate the object of SensorManager class.
Example: SensorManager sMgr;
sMgr = (SensorManager)this.getSystemService(SENSOR_SERVICE);

The next thing you need to do is to instantiate the object of Sensor class by calling the
getDefaultSensor() method of the SensorManager class. Its syntax is given below:
Sensor light;
light = sMgr.getDefaultSensor(Sensor.TYPE_LIGHT);

Maharashtra State Board of Technical Education 145


Mobile Application Development (22617)

Once that sensor is declared, you need to register its listener and override two methods
which are onAccuracyChanged and onSensorChanged. Its syntax is as follows:
sMgr.registerListener(this, light,SensorManager.SENSOR_DELAY_NORMAL);
public void onAccuracyChanged(Sensor sensor, int accuracy)
{}
public void onSensorChanged(SensorEvent event) { }

Methods:
1. getDefaultSensor(int type) :- This method get the default sensor for a given type.
Explain methods
2. getOrientation(float[] R, float[] values) :- This method returns a description of the
current primary clip on the clipboard but not a copy of its data.
3. getInclination(float[] I) :- This method computes the geomagnetic inclination angle
in radians from the inclination matrix.
4. registerListener(SensorListener listener, int sensors, int rate) :-This method
registers a listener for the sensor
5. unregisterListener(SensorEventListener listener, Sensor sensor) :-This method
unregisters a listener for the sensors with which it is registered.
6. getOrientation(float[] R, float[] values) :-This method computes the device's
orientation based on the rotation matrix.
7. getAltitude(float p0, float p) :-This method computes theAltitude in meters from
the atmospheric pressure and the pressure at sea-level.

VIII. Resources required (Additional)

Sr. Instrument Specification Quantity Remarks


No. /Object
Android enabled 2 GB RAM 1 Data cable is
1 smartphone / Android mandatory for
version supporting emulator emulators

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must design more
such questions to ensure the achievement of identified CO.
1. List the best practices for accessing and using sensors.
2. Differentiate between Sensor Class and Sensor Manager Class.

(Space for answers)

Ans 1. Best practice for accessing and using sensors are:

i. Unregister sensor listeners: Always make sure to disable sensors you don’t need,
especially when your activity is paused.

ii. Don’t block the onSensorChanged() method: Sensor data can change at a high rate,
which means the system may call the onSensorChanged(SensorEvent) method quite often.
As a best practice, you should do as little as possible within the onSensorChanged

Maharashtra State Board of Technical Education 146


Mobile Application Development (22617)
(SensorEvent) method so you don’t block it.

iii. Avoid using deprecated methods or sensor types: Several methods and constants
have been deprecated. In particular, the TYPE_ORIENTATION sensor type has been
deprecated.

iv. Verify sensors before you use them: Always verify that a sensor exists on a device
before you attempt to acquire data from it. Don&#39;t assume that a sensor exists
simply because it&#39;s a frequently-used sensor.

v. Choose sensor delays carefully: Sensors can provide data at very high rates.
Allowing the system to send extra data that you don&#39;t need wastes systemresources
and uses battery power.

Ans 2. i. Sensor Class: The android.hardware.Sensor class provides methods to get


information about the sensor such as sensor name, sensor type, sensor resolution,
sensor type etc.

ii. Sensor Manager Class: The android.hardware.SensorManager class provides


methods :
● to get sensor instance,
● to access and list sensors,
● to register and unregister sensor listeners etc.

You can get the instance of SensorManager by calling the method getSystemService() and
passing the SENSOR_SERVICE constant in it.

SensorManager sm = (SensorManager)getSystemService(SENSOR_SERVICE);

Exercise
Note: Faculty must ensure that every group of students use different input value.
(Use blank space for answers or attach more pages if needed)
3. Write a program to changes the background color when device is shuffled.
4. Write a program to display the list of sensors supported by the mobile device.

(Space for answers)


Ans 3) activity_main.xml
<?xml version=”1.0” encoding=”utf-8”?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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:id=”@+id/Layout”
tools:context=”.MainActivity”>
</androidx.constraintlayout.widget.ConstraintLayout>

Maharashtra State Board of Technical Education 147


Mobile Application Development (22617)
MainActivity.java
package com.example.exp22;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import android.content.res.Configuration;
import android.graphics.Color;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity
{ConstraintLayout constraintLayout;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
constraintLayout = findViewById(R.id.Layout);
if(getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_PORTRAIT){
constraintLayout.setBackgroundColor( Color.parseColor(“#2cbdf2”));
}
if(getResources().getConfiguration().orientation ==
Configuration.ORIENTATION_LANDSCAPE){ constraintLayout.setBackgroundColor(Color.parse
Color”#f083f2”));
}}}

Maharashtra State Board of Technical Education 148


Mobile Application Development (22617)

Ans 4) actvity_main.xml

<?xml version=”1.0” encoding=”utf-8”?>


<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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”
tools:context=”.MainActivity”>
<ListView
android:id=”@+id/listView1”
android:layout_width=”match_parent”
android:layout_height=”match_parent” />
</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java

package com.example.exp22_1;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.os.Build;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.List;
public class MainActivity extends AppCompatActivity
{SensorManager smm;
List<Sensor> sensor;
ListView lv;
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
smm = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
lv = (ListView) findViewById (R.id.listView1);
sensor = smm.getSensorList(Sensor.TYPE_ALL);
lv.setAdapter(new ArrayAdapter<Sensor>(this,android.R.layout.simple_list_item_1,
sensor));
}
}

Maharashtra State Board of Technical Education 149


Mobile Application Development (22617)

Maharashtra State Board of Technical Education 150


Mobile Application Development (22617)

X. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XI. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of student Team Members

1 Gaurang Jadhav
2 Shweta Gupta
3 Heet Zatakia

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 151


Mobile Application Development (22617)

Practical No. 23: Develop a program to build Camera.

I. Practical Significance:
The Android framework includes support for various cameras and camera features
available on devices, allowing you to capture pictures and videos in your application.

II. Relevant Program Outcomes (POs)


PO2- Discipline knowledge
PO3- Experiments and practice
PO4. Engineering tools.
PO5.The engineer and society.
PO7- Ethics

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to Launch the existing camera application.
2. Able to use the camera API to integrate the camera in anyapplication.

IV. Relevant Course Outcome(s)


1. Configure Android environment and development tools.
2. Develop rich user Interfaces by using layouts and controls.

V. Practical Outcome (PrOs)


Develop a program for Camera

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


Camera can be used in your application in following ways.
1. Using existing android camera application in our application
2. Directlyusing Camera API provided by android in our application
You will use MediaStore.ACTION_IMAGE_CAPTURE to launch an existing camera
application installed on your phone. Its syntax is given below:
Intent intent = new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

We will be using the camera API to integrate the camera in our application. First you
will need to initialize the camera object using the static method provided by the api
called Camera. Open. Its syntax is:
Camera object = null;
object = Camera.open();
Methods:
1. startActivityForResult(Intent intent, int requestCode, Bundle options) It starts an
activity, but can take extra bundle of options withit.
2. startActivityFromChild(Activity child, Intent intent, int requestCode) It launches

Maharashtra State Board of Technical Education 152


Mobile Application Development (22617)

the activity when your activity is child of any otheractivity.


3. startActivityFromChild(Activity child, Intent intent, int requestCode, Bundle
options) It work same as above, but it can take extra values in the shape of bundle
with it.
4. startActivityFromFragment(Fragment fragment, Intent intent, int requestCode)It
launches activity from the fragment you are currentlyinside.
5. startActivityFromFragment(Fragment fragment, Intent intent, intrequestCode,
Bundle options) It not only launches the activity from the fragment, but can take
extra values withit.

VIII. Resources required (Additional)

Sr. No. Instrument Specification Quantity Remarks


/Object
Android enabled 2 GB RAM 1 Data cable is
1 smartphone / Android mandatory for
version supportingemulator emulators

IX. Practical related Questions


Note: Below given are few sample questions for reference. Teachers must design more
such questions to ensure the achievement of identified CO.
1. List all the methods related to camera class.
2. Explain the method that is used to detect the face.

(Space for answers)


Ans 1) List of all methods related to camera class are as follows:
1. addCallbackBuffer(byte[] callbackBuffer)
2. autoFocus(Camera.AutoFocusCallback cb)
3. cancelAutoFocus()
4. enableShutterSound(boolean enabled)
5. getCameraInfo(int cameraId, Camera.CameraInfo cameraInfo)
6. getNumberOfCameras()
7. getParameters()
8. lock()
9. open()
10. open(int cameraId)
11. reconnect()
12. release()
13. setAutoFocusMoveCallback(Camera.AutoFocusMoveCallback cb)
14. setDisplayOrientation(int degrees)
15. setErrorCallback(Camera.ErrorCallback cb)

Maharashtra State Board of Technical Education 153


Mobile Application Development (22617)

Ans 2) startFaceDetection() method is used to detect the face.


X. Exercise
Note: Faculty must ensure that every group of students use different input value. (Solve
any one of the following. Use blank space for answers or attach more pages if needed)
1. Write a program to capture an image and display it using image view.
2. Write a program to record a video using various camera methods.

(Space for answers)

Ans 1) activity_main.xml
<LinearLayout xmlns: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”
tools:context=”.MainActivity”
android:orientation=”vertical”>
<ImageView
android:id=”@+id/imageView”
android:layout_width=”fill_parent”
android:layout_height=”403dp”
android:layout_centerHorizontal=”true” />
<Button
android:id=”@+id/button”
android:layout_width=”match_parent”
android:layout_height=”73dp”
android:fontFamily=”@font/poppins_medium”
android:text=”Click here to capture image using camera”/>
</LinearLayout>

MainActivity.java
package com.example.exp23;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import android.Manifest;

Maharashtra State Board of Technical Education 154


Mobile Application Development (22617)
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity
{Button button ;
ImageView imageView ;
public static final int RequestPermissionCode = 1 ;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button = (Button)findViewById(R.id.button);
imageView = (ImageView)findViewById(R.id.imageView);
EnableRuntimePermission();
button.setOnClickListener(new View.OnClickListener()
{ @Override
public void onClick(View view)
{Intent intent = new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 7);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 7 && resultCode == RESULT_OK)
{Bitmap bitmap = (Bitmap) data.getExtras().get(“data”);
imageView.setImageBitmap(bitmap);
}
}
public void EnableRuntimePermission(){
Maharashtra State Board of Technical Education 155
Mobile Application Development (22617)
if (ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this,Manif
est.permission.CAMERA))
{
Toast.makeText(MainActivity.this,”CAMERA permission allows us to
Access CAMERA app”, Toast.LENGTH_LONG).show();
} else {
ActivityCompat.requestPermissions(MainActivity.this,new
String[]{Manifest.permission.CAMERA}, RequestPermissionCode);
}
}
@Override
public void onRequestPermissionsResult(int RC, String per[], int[] PResult)
{switch (RC) {
case RequestPermissionCode:
if (PResult.length > 0 && PResult[0] == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(MainActivity.this,&quot;Permission Granted, Now your
application can access CAMERA.&quot;, Toast.LENGTH_LONG).show();
} else {
Toast.makeText(MainActivity.this,”Permission Canceled, Now your
application cannot access CAMERA.”, Toast.LENGTH_LONG).show();
}
break;
}
}
}
AndroidManifest.xml

<?xml version=”1.0” encoding=”utf-8”?>


<manifest xmlns:android=”http://schemas.android.com/apk/res/android”
package=”com.example.exp23”>
<uses-permission android:name=”android.permission.CAMERA” />
<uses-feature
android:name=”android.hardware.camera2”
android:required=”true”/>
<application
android:allowBackup=”true”
Maharashtra State Board of Technical Education 156
Mobile Application Development (22617)
android:icon=”@mipmap/ic_launcher”
android:label=”@string/app_name”
android:roundIcon=”@mipmap/ic_launcher_round”
android:supportsRtl=”true”
android:theme=”@style/Theme.Exp23”>
<activity android:name=”.MainActivity”>
<intent-filter>
<action android:name=”android.intent.action.MAIN” />
<category android:name=”android.intent.category.LAUNCHER”/>
</intent-filter>
</activity>
<meta-data
android:name=”preloaded_fonts”
android:resource=”@array/preloaded_fonts”/>
</application>
</manifest>

Maharashtra State Board of Technical Education 157


Mobile Application Development (22617)

Ans 2) activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:context=".MainActivity"
android:orientation="vertical">
<Button
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="Capture Video"
android:onClick="captureVideo"
android:layout_gravity="center_horizontal"
android:layout_marginTop="150dp"
/>
<Button
android:layout_width="250dp"
android:layout_height="wrap_content"
android:text="Play Video"
android:onClick="playVideo"
android:layout_gravity="center_horizontal"
android:layout_marginTop="25dp"
/>
</LinearLayout>
MainActivty.java
package com.example.exp23_2;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
public class MainActivity extends AppCompatActivity
{private static int VIDEO_REQUEST = 101;
private Uri videoUri = null;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void captureVideo(View view) {
Intent videoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if(videoIntent.resolveActivity(getPackageManager())!=null)
{ startActivityForResult(videoIntent,VIDEO_REQUEST);
}
}
public void playVideo(View view) {
Intent playIntent = new Intent(this,VideoPlayActivity.class);
playIntent.putExtra("videoUri", videoUri.toString());
startActivity(playIntent);
Maharashtra State Board of Technical Education 158
Mobile Application Development (22617)
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{super.onActivityResult(requestCode, resultCode, data);
if (requestCode == VIDEO_REQUEST && resultCode == RESULT_OK)
{videoUri = data.getData();
}
}
}
activity_play_video.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns: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"
tools:context=".VideoPlayActivity">
<VideoView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="35dp"
android:id="@+id/videoView"
/>
</RelativeLayout>
VideoPlayActivity.java
package com.example.exp23_2;
import androidx.appcompat.app.AppCompatActivity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.VideoView;
public class VideoPlayActivity extends AppCompatActivity
{private VideoView mVideoView;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video_play);
mVideoView = findViewById(R.id.videoView);
Uri videoUri = Uri.parse(getIntent().getExtras().getString("videoUri"));
mVideoView.setVideoURI(videoUri);
mVideoView.start();
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.exp23_2">
<uses-feature
android:name="android.hardware.camera2"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
Maharashtra State Board of Technical Education 159
Mobile Application Development (22617)
android:supportsRtl="true"
android:theme="@style/Theme.Exp23_2">
<activity android:name=".VideoPlayActivity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

Maharashtra State Board of Technical Education 160


Mobile Application Development (22617)

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of student Team Members

1 Gaurang Jadhav
2 Shweta Gupta
3 Heet Zatakia

Marks Obtained Dated signature of


Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 161


Mobile Application Development (22617)

Practical No. 24: Develop a program for providing Bluetooth connectivity.

I. Practical Significance
Bluetooth is a way to send or receive data between two different devices. Android
platform includes support for the Bluetooth framework that allows a device to
wirelessly exchange data with other Bluetooth devices.

II. Relevant Program Outcomes (POs)


PO2- Discipline knowledge
PO3- Experiments and practice
PO4- Engineering tools.
PO7- Ethics

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to communicate with Bluetoothhardware.
2. Able to integrate Bluetooth in any application.

IV. Relevant Course Outcome(s)


1. Configure Android environment and development tools.
2. Develop rich user Interfaces by using layouts and controls.
3. Use User Interface components for android application development.

V. Practical Outcome (PrOs)


Develop a program for Bluetooth.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team.
2. Follow ethical Practices.

VII. Minimum Theoretical Background


Android provides Bluetooth API to perform these different operations.
1. Scan for other Bluetooth devices
2. Get a list of paired devices.
3. Connect to other devices through service discovery.
Android provides Bluetooth Adapter class to communicate with Bluetooth. Create an
object of this calling by calling the static method getDefaultAdapter(). Its syntax is
given below.
private BluetoothAdapter BA;
BA = BluetoothAdapter.getDefaultAdapter();

In order to enable the Bluetooth of your device, call the intent with the following
Bluetooth constant ACTION_REQUEST_ENABLE. Its syntax is.
Intent turnOn = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(turnOn, 0);

Maharashtra State Board of Technical Education 162


Mobile Application Development (22617)

Once you enable the Bluetooth, you can get a list of paired devices by calling
getBondedDevices() method. It returns a set of Bluetooth devices. Its syntax is.
private
Set<BluetoothDevice>pairedDevi
ces; pairedDevices =
BA.getBondedDevices();

VIII. Resources required (Additional)

Sr. Instrument Specification Quantity Remarks


No. /Object
Android enabled 2 GB RAM 1 Data cable is
1 smartphone / Android mandatory
version supporting emulator for emulators

IX. Practical related Questions


Note:Belowgivenarefewsamplequestionsforreference. Teachersmustdesign more
such questions to ensure the achievement of identified CO.
1. Name the methods which are used to enable and disable Bluetooth adapter.
2. Explain the purpose of ACTION_REQUEST_DISCOVERABLE Constant.
3. List the uses of setName(String name)method.

(Space for answers)

Ans 1) enable() and disable() methods are used to enable and disable Bluetooth adapters.
Ans 2) ACTION_REQUEST_DISCOVERABLE constant is used for turn on discovery of
bluetooth.
Ans 3) T he setName() method provided by java. lang. Thread class is used to change the name of
the thread and setName assigns a name to an object.
X. Exercise
Note: Faculty must ensure that every group of students use different input value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to turn on, get visible, list devices and turnoff
Bluetooth with the help of following GUI.

Maharashtra State Board of Technical Education 163


Mobile Application Development (22617)
(Space for answers)

Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<androidx.constraintlayout.widget.ConstraintLayoutxmlns:android="http://schemas.android.com/a
pk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:transitionGroup="true"
tools:context=".MainActivity">

<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="56dp"
android:layout_marginTop="72dp"
android:text="Bluetooth_example"
android:textSize="35dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="54dp"
android:text="Turn On"
app:layout_constraintEnd_toStartOf="@+id/button2"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView"
android:clickable="true"
android:onClick="on"
/>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="54dp"
android:text="ListDevices"
app:layout_constraintEnd_toStartOf="@+id/button3"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/button"
app:layout_constraintTop_toBottomOf="@+id/textView"
android:onClick="list"/>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Maharashtra State Board of Technical Education 164
Mobile Application Development (22617)
android:layout_marginTop="54dp"
android:text="Turn Off"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/button2"
app:layout_constraintTop_toBottomOf="@+id/textView"
android:onClick="off"/>
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="136dp"
android:layout_marginTop="40dp"
android:text="Get Visisble"

app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button2"
android:onClick="visible"/>
<ListView
android:id="@+id/listView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="84dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button4" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="11dp"
android:layout_marginTop="27dp"
android:text="Paired Device"
android:textColor="#ff34ff06"
android:textSize="25dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button4" />
</androidx.constraintlayout.widget.ConstraintLayout>

MainActivity.java

package com.example.exp24;
import androidx.appcompat.app.AppCompatActivity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Set;
Maharashtra State Board of Technical Education 165
Mobile Application Development (22617)
public class MainActivity extends AppCompatActivity
{Button b1,b2,b3,b4;
private BluetoothAdapter BA;
private Set<BluetoothDevice>pairedDevices;
ListView lv;
@Override
protected void onCreate(Bundle savedInstanceState)
{super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1 = findViewById(R.id.button);
b2 = findViewById(R.id.button2);
b3 = findViewById(R.id.button3);
b4 = findViewById(R.id.button4);
BA = BluetoothAdapter.getDefaultAdapter();
lv = findViewById(R.id.listView);
}
public void on(View
v){if(!BA.isEnabled()
){
Intent turnOn = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(turnOn,0);
Toast.makeText(getApplicationContext(),"Turned On", Toast.LENGTH_LONG).show();
}else {
Toast.makeText(getApplicationContext(),"Already On", Toast.LENGTH_LONG).show();
}
}
public void off(View
v){BA.disable();
Toast.makeText(getApplicationContext(),"Turned Off", Toast.LENGTH_LONG).show();
}
public void visible(View v){
Intent getVisible = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
startActivityForResult(getVisible,0);
}
public void list(View
v){ pairedDevices =
BA.getBondedDevices();ArrayList list =
new ArrayList();
for(BluetoothDevicebt : pairedDevices) list.add(bt.getName());
Toast.makeText(getApplicationContext(),"Show Paired Devices",
Toast.LENGTH_LONG).show();
final ArrayAdapter adapter = new ArrayAdapter(this,
android.R.layout.simple_list_item_1,list);
lv.setAdapter(adapter);
}
}

Android_Manifest.xml

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.exp24">
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
Maharashtra State Board of Technical Education 166
Mobile Application Development (22617)
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Exp24">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
</application>
</manifest>

XI. References / Suggestions for further Reading


1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1. Logic Formation 10%
2. Debugging ability 15%
3. Follow ethical practices 5%
Product related (15 Marks) 70%
4. Interactive GUI 20%
5. Answer to Practical related questions 20%
6. Expected Output 20%
7. Timely Submission 10%
Total (25 Marks) 100%

List of student Team Members

1 Gaurang Jadhav
2 Shweta Gupta
3 Heet Zatakia

Maharashtra State Board of Technical Education 167


Mobile Application Development (22617)

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

Maharashtra State Board of Technical Education 168


Practical No. 24: Develop a program for providing Bluetooth connectivity.

I. Practical Significance
Bluetooth is a way to send or receive data between two different devices. Android
platform includes support for the Bluetooth framework that allows a device to wirelessly
exchange data with other Bluetooth devices.

II. Relevant Program Outcomes (POs)


PO2- Discipline knowledge
PO3- Experiments and
practice PO4- Engineering
tools.
PO7- Ethics

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to communicate with Bluetooth hardware.
2. Able to integrate Bluetooth in any application.

IV. Relevant Course Outcome(s)


1. Configure Android environment and development tools.
2. Develop rich user Interfaces by using layouts and controls.
3. Use User Interface components for android application development.

V. Practical Outcome (PrOs)


Develop a program for Bluetooth.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in a team.
2. Follow ethical Practices.

VII. Minimum Theoretical Background


Android provides Bluetooth API to perform these different operations.
1. Scan for other Bluetooth devices
2. Get a list of paired devices.
3. Connect to other devices through service discovery.
Android provides Bluetooth Adapter class to communicate with Bluetooth. Create an
object of this calling by calling the static method getDefaultAdapter(). Its syntax is given
below.
private BluetoothAdapter BA;
BA = BluetoothAdapter.getDefaultAdapter();

In order to enable the Bluetooth of your device, call the intent with the following Bluetooth
constant ACTION_REQUEST_ENABLE. Its syntax is.
Intent turnOn = new
Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(turnOn, 0);
Once you enable the Bluetooth, you can get a list of paired devices by calling
getBondedDevices() method. It returns a set of Bluetooth devices. Its syntax is.
private
Set<BluetoothDevice>pairedDevi
ces; pairedDevices =
BA.getBondedDevices();

VIII. Resources required (Additional)

Sr Instrume Specificati Quantit Remarks


. nt on y
No /Object
.
Android enabled 2 GB RAM 1 Data cable
1 smartphone / Android is
version supporting mandatory
emulator for
emulators

IX. Practical related Questions


Note: Below given are a few sample questions for reference. Teachers
must design more such questions to ensure the achievement of identified CO.
1. Name the methods which are used to enable and disable Bluetooth adapters.
2. Explain the purpose of ACTION_REQUEST_DISCOVERABLE Constant.
3. List the uses of the setName(String name)method.

(Space for answers)


Ans 1) enable() and disable() methods are used to enable and disable Bluetooth
adapters.

Ans 2) ACTION_REQUEST_DISCOVERABLE constant is used for turn on


discovery of bluetooth.

Ans 3) The setName() method provided by java. lang. Thread class is used to
change the name of the thread and setName assigns a name to an object.
X. Exercise
Note: Faculty must ensure that every group of students use different input
value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to turn on, get visible, list devices and turn off
Bluetooth with the help of following GUI.

(Space for answers)


Ans 1) acitvity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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"
tools:context=".MainActivity"
android:transitionGroup="true"

android:id="@+id/relativeLayout">

<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:text="Bluetooth Example"
android:textSize="35dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="28dp"
android:layout_toStartOf="@+id/imageView"
android:layout_toLeftOf="@+id/imageView"
android:clickable="true"
android:onClick="on"
android:text="Turn On"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textview" />

<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textview"
android:layout_alignBottom="@+id/button"
android:layout_centerHorizontal="true"
android:layout_marginStart="144dp"
android:layout_marginLeft="144dp"
android:layout_marginTop="24dp"
android:onClick="visible"

android:text="Get visible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button3" />

<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="136dp"
android:layout_marginLeft="136dp"
android:layout_marginTop="28dp"
android:onClick="list"
android:text="List devices"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textview" />

<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="28dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:onClick="off"
android:text="turn off"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textview" />

<ListView
android:id="@+id/listView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView2"
android:layout_alignStart="@+id/button"
android:layout_alignLeft="@+id/button"
android:layout_alignParentBottom="true"
app:layout_constraintStart_toStartOf="@+id/button"
app:layout_constraintTop_toBottomOf="@+id/textView2" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/button4"
android:layout_alignStart="@+id/listView"
android:layout_alignLeft="@+id/listView"

android:layout_marginStart="24dp"
android:layout_marginLeft="24dp"
android:layout_marginTop="24dp"
android:text="Paired devices:"
android:textColor="#ff34ff06"
android:textSize="25dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button2" />

</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
package com.example.exp24;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Set;
public class MainActivity extends Activity {
Button b1,b2,b3,b4;
private BluetoothAdapter BA;
private Set<BluetoothDevice>pairedDevices;

ListView lv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1 = (Button) findViewById(R.id.button);
b2=(Button)findViewById(R.id.button2);
b3=(Button)findViewById(R.id.button3);
b4=(Button)findViewById(R.id.button4);
BA = BluetoothAdapter.getDefaultAdapter();

lv = (ListView)findViewById(R.id.listView);
}
public void on(View v){
if (!BA.isEnabled()) {
Intent turnOn = new
Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(turnOn, 0);
Toast.makeText(getApplicationContext(), "Turned
on",Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "Already on",
Toast.LENGTH_LONG).show();
}
}
public void off(View v){
BA.disable();
Toast.makeText(getApplicationContext(), "Turned off"
,Toast.LENGTH_LONG).show();
}
public void visible(View v){
Intent getVisible = new
Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
startActivityForResult(getVisible, 0);
}
public void list(View v){
pairedDevices = BA.getBondedDevices();
ArrayList list = new ArrayList();
for(BluetoothDevice bt : pairedDevices) list.add(bt.getName());
Toast.makeText(getApplicationContext(), "Showing Paired

Devices",Toast.LENGTH_SHORT).show();
final ArrayAdapter adapter = new
ArrayAdapter(this,android.R.layout.simple_list_item_1, list);
lv.setAdapter(adapter);
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.example.exp24">
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Exp24">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
XI. References / Suggestions for further Reading
1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1 Logic Formation 10%
.
2 Debugging ability 15%
.
3 Follow ethical practices 5%
.
Product related (15 Marks) 70%
4 Interactive GUI 20%
.
5 Answer to Practical related questions 20%
.
6 Expected Output 20%
.
7 Timely Submission 10%
.
Total (25 Marks) 100%

List of student Team Members


1 Heet Zatakia

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)
Practical No. 26: Perform Async task using SQLite.

I. Practical Significance
Android AsyncTask is an abstract class provided by Android which gives us the liberty
to perform heavy tasks in the background and keep the UI thread light thus making the
application more responsive.

II. Relevant Program Outcomes (POs)


PO2- Discipline knowledge
PO3- Experiments and
practice

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to develop the application using the Async task.
2. Able to keep the GUI light for heavy database applications.

IV. Relevant Course Outcome(s)


1. Configure Android environment and development tools.
2. Develop rich user Interfaces by using layouts and controls.
3. Create Android application using database

V. Practical Outcome (PrOs)


Demonstrate Async tasks using SQLite.

VI. Relevant Affective Domain related Outcomes


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


Android application runs on a single thread when launched. Due to this single thread
model, tasks that take longer time to fetch the response can make the application non-
responsive. To avoid this, we use android AsyncTask to perform the heavy tasks in
background on a dedicated thread and pass the results back to the UI thread. Hence use
of AsyncTask in android application keeps the UI thread responsive at all times.

VIII. Resources required (Additional)

S Instrument Specificatio Quantit Remarks


r /Object n y
.
N
o.
Android enabled smartphone 2 GB RAM 1 Data cable
/ Android version supporting is
1
emulator mandatory
for
emulators
IX. Practical related Questions
Note: Below given are a few sample questions for reference.
Teachers must design more such questions to ensure the achievement of
identified CO.
1. List the basic methods used in an android AsyncTaskclass.
2. Differentiate between AsyncTask andServices.
3. Name the method used, if a process takes a long time to do its work?

(Space for answers)


Ans 1) Basic methods used in an android AsyncTaskclass are as follows:
1. doInBackground() : This method contains the code which needs to be
executed in background. In this method we can send results multiple times to
the UI thread by the publishProgress() method. To notify that the background
processing has been completed we just need to use the return statements
2. onPreExecute() : This method contains the code which is executed before the
background processing starts
3. onPostExecute() : This method is called after the doInBackground method
completes processing. Result from doInBackground is passed to this method
4. onProgressUpdate() : This method receives progress updates from
doInBackground method, which is published via publishProgress method, and
this method can use this progress update to update the UI thread

Ans 2) In some cases it is possible to accomplish the same task with either an
AsyncTask or a Service however usually one is better suited to a task than the other.
AsyncTasks are designed for once-off time-consuming tasks that cannot be run on the
UI thread. A common example is fetching/processing data when a button is pressed.
Services are designed to be continually running in the background. In the example
above of fetching data when a button is pressed, you could start a service, let it fetch
the data, and then stop it, but this is inefficient. It is far faster to use an AsyncTask
that will run once, return the data, and be done.
If you need to be continually doing something in the background, though, a Service
is your best bet. Examples of this include playing music, continually checking for new
data, etc.

Ans 3) AsyncTasks should ideally be used for short operations (a few seconds at the
most.) If you need to keep threads running for long periods of time, it is highly
recommended you use the various APIs provided by the java.util.concurrent package
such as Executor, ThreadPoolExecutor and FutureTask.
X. Exercise
Note: Faculty must ensure that every group of students use different input values.
(Use blank space for answers or attach more pages if needed)
1. Write a program to insert data in SQLite database using AsyncTask

(Space for answers)

Ans1) 1. activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<androidx.constraintlayout.widget.Constra android:id="@+id/buttonNormalInsert"
intLayout
android:layout_width="wrap_content"
xmlns:android="http://schemas.android.co
m/apk/res/android" android:layout_height="wrap_content"

xmlns:app="http://schemas.android.com/a android:layout_below="@+id/editTextRec
pk/res-auto" ordNum"

xmlns:tools="http://schemas.android.com/t android:layout_alignLeft="@+id/editText
ools" RecordNum"
android:layout_width="match_parent" android:layout_marginStart="44dp"
android:layout_height="match_parent" android:layout_marginLeft="44dp"
tools:context=".MainActivity"> android:layout_marginTop="44dp"
<EditText
android:fontFamily="@font/poppins_medi
android:id="@+id/editTextRecordNum" um"
android:layout_width="318dp" android:text="Normal Insert"
android:layout_height="50dp"
app:layout_constraintStart_toStartOf="par
android:layout_alignParentLeft="true" ent"

android:layout_alignParentTop="true" app:layout_constraintTop_toBottomOf="
android:layout_marginStart="44dp" @+id/editTextRecordNum" />
android:layout_marginLeft="44dp" <Button
android:layout_marginTop="124dp" android:id="@+id/buttonFastInsert"
android:ems="10"
android:layout_width="wrap_content"
android:fontFamily="@font/poppins_medi
um" android:layout_height="wrap_content"
android:inputType="number"
android:singleLine="true" android:layout_alignBaseline="@+id/butt
android:textColor="#FFFFFF" onNormalInsert"

app:layout_constraintStart_toStartOf="par android:layout_alignBottom="@+id/butto
ent" nNormalInsert"
android:layout_marginTop="44dp"
app:layout_constraintTop_toTopOf="pare android:layout_marginEnd="48dp"
nt" android:layout_marginRight="48dp"
tools:ignore="MissingConstraints" />
<Button android:layout_toRightOf="@+id/buttonN
ormalInsert" android:layout_alignLeft="@+id/buttonNo
rmalInsert"
android:fontFamily="@font/poppins_medi android:layout_marginStart="16dp"
um" android:layout_marginLeft="16dp"
android:text="Fast Insert" android:layout_marginTop="36dp"

app:layout_constraintEnd_toEndOf="pare android:fontFamily="@font/poppins_medi
nt" um"
android:padding="10dp"
app:layout_constraintTop_toBottomOf=" android:text="Status"
@+id/editTextRecordNum" /> android:textColor="#FFFFFF"
<TextView android:textSize="18sp"
android:id="@+id/textViewStatus"
app:layout_constraintStart_toStartOf="par
android:layout_width="wrap_content" ent"

android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="
@+id/buttonNormalInsert" />
android:layout_below="@+id/buttonNorm </androidx.constraintlayout.widget.Constr
alInsert" aintLayout>

2. MainActivity.java

package com.example.coexp26; case R.id.buttonFastInsert:


new
import android.os.AsyncTask; AsyncInsertData("fast").execute();
import android.os.Bundle; break;
import android.app.Activity; }
import android.view.View; }
import android.widget.EditText; };
import android.widget.TextView; // EditText for entering desired
public class MainActivity extends Activity number of records to be inserted
{ editTextRecordNum = (EditText)
findViewById(R.id.editTextRecordNum);
final String TAG = "MainActivity.java"; // Button for normal and fast insert
EditText editTextRecordNum;
TextView tvStatus; findViewById(R.id.buttonNormalInsert).s
etOnClickListener(handler);
@Override
protected void onCreate(Bundle findViewById(R.id.buttonFastInsert).setO
savedInstanceState) { nClickListener(handler);
super.onCreate(savedInstanceState); // status TextView
tvStatus = (TextView)
setContentView(R.layout.activity_main); findViewById(R.id.textViewStatus);
View.OnClickListener handler = new }
View.OnClickListener() { // we used AsyncTask so it won't block
public void onClick(View v) { the UI thread during inserts.
switch (v.getId()) { class AsyncInsertData extends
case R.id.buttonNormalInsert: AsyncTask<String, String, String> {
new DatabaseHandler databaseHandler;
AsyncInsertData("normal").execute(); String type;
break;
long timeElapsed; long lStartTime =
protected AsyncInsertData(String System.nanoTime();
type){ if (type.equals("normal")) {
this.type = type;
this.databaseHandler = new databaseHandler.insertNormal(insertCount
DatabaseHandler(MainActivity.this); );
} } else {
// @type - can be 'normal' or 'fast'
@Override databaseHandler.insertFast(insertCount);
protected void onPreExecute() { }
super.onPreExecute(); // execution finished
tvStatus.setText("Inserting " + long lEndTime =
editTextRecordNum.getText() + " System.nanoTime();
records..."); // display execution time
} timeElapsed = lEndTime -
@Override lStartTime;
protected String } catch (Exception e) {
doInBackground(String... aurl) { e.printStackTrace();
try { }
// get number of records to be return null;
inserted }
int insertCount = protected void onPostExecute(String
Integer.parseInt(editTextRecordNum.getT unused) {
ext().toString()); tvStatus.setText("Done inserting "
+ databaseHandler.countRecords() + "
// empty the table records. Time elapsed: " + timeElapsed /
1000000 + " ms.");
databaseHandler.deleteRecords(); }}}
// keep track of execution time

3. DatabaseHandler.java

package com.example.coexp26; "DatabaseHandler.java";


// database version
import android.content.ContentValues; private static final int
import android.content.Context; DATABASE_VERSION = 7;
import android.database.Cursor; // database name
import protected static final String
android.database.sqlite.SQLiteDatabase; DATABASE_NAME = "NinjaDatabase2";
import // table details
android.database.sqlite.SQLiteOpenHelper public String tableName = "locations";
; public String fieldObjectId = "id";
import public String fieldObjectName =
android.database.sqlite.SQLiteStatement; "name";
import android.util.Log; public String fieldObjectDescription =
public class DatabaseHandler extends "description";
SQLiteOpenHelper { // constructor
// for our logs
public static final String TAG = public DatabaseHandler(Context
context) { }
super(context, DATABASE_NAME, db.setTransactionSuccessful();
null, DATABASE_VERSION);
} db.endTransaction();
db.close();
// creating table
}
@Override
// inserts the record without using
public void onCreate(SQLiteDatabase
db) { transaction and prepare statement
String sql = "";
sql += "CREATE TABLE " + public void insertNormal(int
tableName; insertCount){
sql += " ( "; try{
sql += fieldObjectId + " INTEGER SQLiteDatabase db =
this.getWritableDatabase();
PRIMARY KEY AUTOINCREMENT, ";
sql += fieldObjectName + " TEXT, "; for(int x=1; x<=insertCount; x++){
sql += fieldObjectDescription + " ContentValues values = new
TEXT "; ContentValues();
values.put(fieldObjectName,
sql += " ) ";
db.execSQL(sql); "Name # " + x);
String INDEX = "CREATE UNIQUE
values.put(fieldObjectDescription,
INDEX locations_index ON "
+ tableName + " (name, "Description # " + x);
description)"; db.insert(tableName, null,
db.execSQL(INDEX); values);
} }
// When upgrading the database, it will db.close();
drop the current table and recreate. }catch(Exception e){
@Override e.printStackTrace();
public void onUpgrade(SQLiteDatabase }}
db, int oldVersion, int newVersion) { // deletes all records
String sql = "DROP TABLE IF public void deleteRecords(){
EXISTS " + tableName; SQLiteDatabase db =
db.execSQL(sql); this.getWritableDatabase();
onCreate(db); db.execSQL("delete from "+
} tableName);
// insert data using transaction and db.close();
prepared statement }
public void insertFast(int insertCount) { // count records
// you can use INSERT only public int countRecords(){
String sql = "INSERT OR REPLACE SQLiteDatabase db =
INTO " + tableName + " ( name, this.getWritableDatabase();
description ) VALUES ( ?, ? )"; Cursor cursor =
SQLiteDatabase db = db.rawQuery("SELECT count(*) from " +
this.getWritableDatabase(); tableName, null);
db.beginTransactionNonExclusive(); cursor.moveToFirst();
// db.beginTransaction(); int recCount = cursor.getInt(0);
SQLiteStatement stmt = cursor.close();
db.compileStatement(sql); db.close();
for(int x=1; x<=insertCount; x++){ return recCount;
stmt.bindString(1, "Name # " + x); }}
stmt.bindString(2, "Description # "
+ x);
stmt.execute();
stmt.clearBindings();
XI. References / Suggestions for further Reading
1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1 Logic Formation 10%
.
2 Debugging ability 15%
.
3 Follow ethical practices 5%
.
Product related (15 Marks) 70%
4 Interactive GUI 20%
.
5 Answer to Practical related questions 20%
.
6 Expected Output 20%
.
7 Timely Submission 10%
.
Total (25 Marks) 100%

List of student Team Members


1 Heet Zatakia

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)
Practical No. 28: Create login application where you will have to validate
username and password till the username and password
is not validated, login button should remain disabled.

I. Practical Significance
Today Login and Registration form in Android are part of every application out there.
So, when we are programming, we work with many registration forms. Forms can be
very different from a simple login or registration to a complex ordering form for any
application.

II. Relevant Program Outcomes (POs)


PO1- Basic knowledge
PO2- Discipline
knowledge
PO3- Experiments and
practice PO7- Ethics

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to develop various registration forms.
2. Able to develop the application with various kinds of validations.

IV. Relevant Course Outcome(s)


1. Configure Android environment and development tools.
2. Develop rich user Interfaces by using layouts and controls.
3. Use User Interface components for android application
development.

V. Practical Outcome (PrOs)


Create a sample application with a login module. (Check username and password) On
successful login, Change Text View “Login Successful”. And on login fail, alert the
user using Toast “Login fail”.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


With registration, how you can check data that the user has entered with simple
validation. Validation can check many conditions. We can verify if an email address is
a valid email and if a user entered all the required data, for instance, we check if Edit
Text is empty for the first and last name. We can prepare a way to notify the user that
the data is not valid. On login activity, we should check for password length. There are
a few things login and registration form need:
● Clean user interface.
● Validation (check if the email is an email and if the user entered all the data).
● Notifications for the user that the data is incorrect.
● Instructions for the user (e.g. how many characters are required for password).

VIII. Resources required (Additional)

S Instrume Specificati Quanti Remarks


r. nt on ty
N /Object
o.
Android 2 GB RAM 1 Data cable
enable is
1 d smartphone / mandatory
Android version for
supporting emulators
emulator

IX. Practical related Questions


Note: Below given are a few sample questions for reference. Teachers
must design more such questions to ensure the achievement of identified CO.
1. Explain validation of user input?
2. List and explain various GUI components used to design the login
form with validation.
3. Differentiate between Text View and Edit Text View.

(Space for answers)


Ans 1) Input Validation eliminates the errors that can be done by the user while giving
inputs to our app. For example if we want to get the user's email we can check if the
entered email is a valid email or not before storing it inside the database.

Ans 2) Various GUI components used to design the login form with validation are as
follows:
1. Add the first EditText for the first name.
a. Name it "firstName" (use the id attribute to name the component).
b. Set text to "".
c. Set the hint to "First name".
d. This one should have 3 constraints; one links to the top of the screen, second
to left border and third to the right border.
2. Add EditText for the last name.
a. Name it "lastName".
b. Set text to "".
c. Set the hint to "First name".
d. This one should have 3 constraints; one linked to the bottom of "First name",
second to left border and third to the right border.
3. Add EditText for postal address.
a. Name it "address".
b. Set text to "".

c. Set a hint to "Postal address".


d. This one should have 3 constraints; one linked to the bottom of "Last name",
second to left border and third to the right border.
4. Add EditText for email.
a. Name it "email".
b. Set text to "".
c. Set a hint to "Email".
d. This one should have 3 constraints; one linked to the bottom of "Postal
address", second to left border and third to the right border.
5. Add a Button for registration.
a. Name it "registration".
b. Set text to "Registration".

Ans 3) EditText is used for user input. TextView is used to display text and is not
editable by the user. TextView is the widget used when you want the user to View
the Text (such as a label, etc) and EditText used when you want the user to be able to
edit the text.

X. Exercise
Note: Faculty must ensure that every group of students use different input
values.
(Use blank space for answers or attach more pages if needed)
1. Write a program to create the login form with necessary validations like length of
username and password, empty text fields, count of unsuccessful login attempts.
Display the login successful/Unsuccessful toastmessage.

(Space for answers)


Ans1) 1. activity_main.xml

<?xml version="1.0" encoding="utf-8"?> xmlns:tools="http://schemas.android.com/t


<RelativeLayout ools"
android:layout_width="match_parent"
xmlns:android="http://schemas.android.co android:layout_height="match_parent"
m/apk/res/android" tools:context=".MainActivity">
<EditText
xmlns:app="http://schemas.android.com/a android:id="@+id/User_password"
pk/res-auto"
android:layout_width="wrap_content"
android:textColor="#FFFFFF"
android:layout_height="wrap_content" android:textSize="40dp" />
<Button
android:layout_below="@+id/User_email" android:id="@+id/User_login"
android:layout_width="150dp"
android:layout_alignParentStart="true"
android:layout_height="wrap_content"

android:layout_alignParentLeft="true" android:layout_below="@+id/User_passw
ord"
android:layout_alignParentEnd="true"
android:layout_centerHorizontal="true"
android:layout_alignParentRight="true" android:layout_marginTop="25dp"
android:layout_marginStart="49dp" android:text="Login" />
android:layout_marginLeft="49dp" <EditText
android:layout_marginTop="25dp" android:id="@+id/User_email"
android:layout_marginEnd="53dp" android:layout_width="310dp"
android:layout_marginRight="53dp"
android:ems="10" android:layout_height="wrap_content"
android:hint="Password:"
android:inputType="textPassword" android:layout_below="@+id/User_Text"
android:padding="10dp" />
<TextView
android:id="@+id/User_Text" android:layout_alignParentStart="true"

android:layout_width="wrap_content" android:layout_alignParentLeft="true"

android:layout_height="wrap_content" android:layout_alignParentEnd="true"

android:layout_alignParentTop="true" android:layout_alignParentRight="true"
android:layout_marginStart="49dp"
android:layout_alignParentEnd="true" android:layout_marginLeft="49dp"
android:layout_marginTop="80dp"
android:layout_alignParentRight="true" android:layout_marginEnd="52dp"
android:layout_marginTop="113dp" android:layout_marginRight="52dp"
android:layout_marginEnd="106dp" android:hint="Email:"
android:layout_marginRight="106dp"
android:inputType="textEmailAddress"
android:fontFamily="@font/poppins_semi android:padding="10dp" />
bold" </RelativeLayout>
android:text="User Login"
2. MainActivity.java

package com.example.coexp28; Uemail.getText().toString().trim();


import Upassword =
androidx.appcompat.app.AppCompatActiv Upass.getText().toString().trim();
ity; if(Uuseremail.isEmpty()) {
import android.content.Intent; Uemail.setError("Enter an e-mail,it
import is blank");
android.icu.text.UnicodeSetSpanner; Uemail.requestFocus();
import android.os.Bundle; return;
import android.util.Patterns; }
import android.view.View;
import android.widget.Button; if(!Patterns.EMAIL_ADDRESS.matcher(U
useremail).matches()){
import android.widget.EditText;
Uemail.setError("Enter an e-
import android.widget.Toast;
mail");
public class MainActivity extends
Uemail.requestFocus();
AppCompatActivity {
Button login; return;
EditText Uemail,Upass; }
public String Uuseremail,Upassword; if(Upassword.isEmpty()) {
@Override Upass.setError("Enter a password ,
protected void onCreate(Bundle it is blank");
savedInstanceState) { Upass.requestFocus();
super.onCreate(savedInstanceState); return;
}
setContentView(R.layout.activity_main); if(Upassword.length()<6){
login = Upass.setError("Minimum length is
findViewById(R.id.User_login); 6 characters");
login.setOnClickListener(new Upass.requestFocus();
View.OnClickListener() { return;
@Override }
public void onClick(View v) {
check(); if(Uuseremail.equals("[email protected]
}}); om") && Upassword.equals("heetzatakia
@10")){
Uemail = Toast.makeText(MainActivity.this,"Welco
findViewById(R.id.User_email); me User",Toast.LENGTH_LONG).show();
Upass = Intent intent = new
findViewById(R.id.User_password); Intent(MainActivity.this,MainActivity2.cla
}
ss);
public void check(){
startActivity(intent);
Uuseremail =
}
else{ ;
Toast.makeText(this,"Wrong email }
or }
password",Toast.LENGTH_LONG).show() }

3. activity_main2.xml

<?xml version="1.0" encoding="utf-8"?>


<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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"
tools:context=".MainActivity2">
</androidx.constraintlayout.widget.ConstraintLayout>

5. MainActivity2.java

package com.example.coexp28;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity2 extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
}}

5. AndroidMainfest.xml

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.coexp28">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.COEXP28">
<activity android:name=".MainActivity2"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
</application>

</manifest>
XI. References / Suggestions for further Reading
1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1 Logic Formation 10%
.
2 Debugging ability 15%
.
3 Follow ethical practices 5%
.
Product related (15 Marks) 70%
4 Interactive GUI 20%
.
5 Answer to Practical related questions 20%
.
6 Expected Output 20%
.
7 Timely Submission 10%
.
Total (25 Marks) 100%

List of student Team Members


1 Heet Zatakia

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)
Practical No. 29: Develop a program to: a) Send SMS b) Receive SMS

I. Practical Significance
Android devices can send and receive messages to or from any other phone that supports
Short Message Service (SMS). Android offers the Messenger application that can send
and receive SMS messages.

II. Relevant Program Outcomes (POs)


PO2- Discipline knowledge
PO3- Experiments and
practice PO4-Engineering
tools
PO7- Ethics

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Develop the application to send SMS.
2. Develop the application to receive SMS with customized GUI.

IV. Relevant Course Outcome(s)


1. Configure Android environment and development tools.
2. Develop rich user Interfaces by using layouts and controls.
3. Interpret features of Android operating system

V. Practical Outcome (PrOs)


Develop a program to: a) Send SMS b) Receive SMS.

VI. Relevant Affective Domain related Outcomes


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


A host of third-party apps for sending and receiving SMS messages are also available
in Google Play. The SMS protocol was primarily designed for user-to-user
communication and is not well-suited for apps that want to transfer data. You should
not use SMS to send data messages from a web server to your app on a user device.
SMS is neither encrypted nor strongly authenticated on either the network or the device
Access to the SMS features of an Android device is protected by user permissions. Just
as your app needs the user's permission to use phone features, so also does an app need
the user's permission to directly use SMS features.
You have two choices for sending SMS messages:
● Use an implicit Intent to launch a messaging app such as Messenger, with the
ACTION_SENDTOaction.
● Send the SMS message using the sendTextMessage() method or other methods of
the SmsManagerclass.
To receive SMS messages, the best practice is to use the onReceive() method of the
Broadcast Receiver class. The Android framework sends out system broadcasts of
events such as receiving an SMS message, containing intents that are meant to be
received using a Broadcast Receiver. Your app receives SMS messages by listening for
the SMS_RECEIVED_ACTION broadcast.
Methods :
1 ArrayList<String> divideMessage(String text) :-This method divides a message text
into several fragments, none bigger than the maximum SMS message size.
2 static SmsManager getDefault() :- This method is used to get the default instance of
the Sms Manager
3 void sendDataMessage(String destination Address, String scAddress, short
destinationPort, byte[] data, PendingIntent sentIntent, PendingIntent
deliveryIntent):- This method is used to send a data based SMS to a specific
application port.
4 void sendTextMessage(String destinationAddress, String scAddress, String text,
PendingIntent sentIntent, PendingIntent deliveryIntent) :-Send a text based SMS.

VIII. Resources required (Additional)

S Instrume Specificati Quantit Remarks


r. nt on y
N /Object
o.
Android enabled 2 GB RAM 1 Data cable
1 smartphone / Android is
version supporting mandatory
emulator for
emulators

IX. Practical related Questions


Note: Below given are a few sample questions for reference. Teachers
must design more such questions to ensure the achievement of identified CO.
1. Explain the use of SmsManagerClass.
2. List changes that need to be done in AndroidMainfest.XML file to send
and receive messages.

(Space for answers)


Ans 1) SmsManager that supports both GSM and CDMA. Manages SMS operations
such as sending data, text, and pdu SMS messages. Get this object by calling the
static method SmsManager.

Ans 2) Changes that need to be made in AndroidManifest.xml file to send and


receive messages are as follows:
1. Pass data (the phone number) and the message with the implicit intent.
2. Create an app that sends SMS messages using the SmsManager class.
3. Check for the SMS permission, which can change at any time.
4. Request permission from the user, if necessary, to send SMS messages.
X. Exercise
Note: Faculty must ensure that every group of students use different input value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to send and receive SMS, make use of the following GUI.

(Space for answers)

Ans1) 1. activity_main.xml

<?xml version="1.0" encoding="utf-8"?> ools"


<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.co android:orientation="vertical"
m/apk/res/android" android:padding="16dp"
android:gravity="center_horizontal"
xmlns:app="http://schemas.android.com/a tools:context=".MainActivity">
pk/res-auto"
<EditText
xmlns:tools="http://schemas.android.com/t android:id="@+id/et_phone"
android:padding="12dp"
android:layout_width="match_parent" android:minLines="6"
android:inputType="textMultiLine"
android:layout_height="wrap_content" android:gravity="top"
android:hint="Enter Phone Number" android:layout_marginTop="8dp"
android:padding="12dp"
android:maxLength="10" android:background="@color/cardview_s
android:inputType="phone" hadow_start_color"/>

android:background="@color/cardview_s <Button
hadow_start_color"/> android:id="@+id/bt_send"

<EditText android:layout_width="wrap_content"
android:id="@+id/et_message"
android:layout_height="wrap_content"
android:layout_width="match_parent" android:text="Send SMS"
android:layout_marginTop="32dp"/>
android:layout_height="wrap_content"
android:hint="Enter Message" </LinearLayout>

2. MainActivity.java

package com.example.coexp29;
import androidx.annotation.NonNull; EditText etPhone, etMessage;
import Button btSend;
androidx.appcompat.app.AppCompatActiv
ity; @Override
import androidx.core.app.ActivityCompat; protected void onCreate(Bundle
import savedInstanceState) {
androidx.core.content.ContextCompat; super.onCreate(savedInstanceState);

import android.Manifest; setContentView(R.layout.activity_main);


import android.content.pm.ActivityInfo;
import etPhone =
android.content.pm.PackageManager; findViewById(R.id.et_phone);
import android.os.Bundle; etMessage =
findViewById(R.id.et_message);
import android.telephony.SmsManager; btSend =
import android.view.View;
findViewById(R.id.bt_send);
import android.widget.Button;
import android.widget.EditText; btSend.setOnClickListener(new
import android.widget.Toast; View.OnClickListener() {
@Override
public class MainActivity extends public void onClick(View view) {
AppCompatActivity {
if Toast.LENGTH_LONG).show();
(ContextCompat.checkSelfPermission(Mai }else{
nActivity.this
, Toast.makeText(getApplicationContext(),"
Enter value first.",
Manifest.permission.SEND_SMS)
Toast.LENGTH_SHORT).show();
== }
PackageManager.PERMISSION_GRANTE
D){ }

sendMessage(); @Override
}else{ public void
onRequestPermissionsResult(int
ActivityCompat.requestPermissions(Main requestCode, @NonNull
Activity.this, new @org.jetbrains.annotations.NotNull
String[]{Manifest.permission.SEND_SMS
String[] permissions, @NonNull
}, 100);
@org.jetbrains.annotations.NotNull int[]
}
grantResults) {
}
});
super.onRequestPermissionsResult(request
}
Code, permissions, grantResults);
private void sendMessage() {
if (requestCode == 100 &&
String sPhone =
grantResults.length > 0 &&
etPhone.getText().toString().trim();
grantResults[0]
String sMessage =
==
etMessage.getText().toString().trim();
PackageManager.PERMISSION_GRANTE
D){
if (!sPhone.equals("") &&
!sMessage.equals("")){ sendMessage();
SmsManager smsManager = }else{
SmsManager.getDefault();
Toast.makeText(getApplicationContext(),
smsManager.sendTextMessage(sPhone, "Permission Denied!",
null, sMessage, null, null); Toast.LENGTH_SHORT).show();
}
}
Toast.makeText(getApplicationContext(), }
"SMS sent successfully!",
3. AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>


<manifest
xmlns:android="http://schemas.android.com/ap
k/res/android"
package="com.example.coexp29">
<uses-permission
android:name="android.permission.SEND_SM
S"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"

android:roundIcon="@mipmap/ic_launcher_ro
und"
android:supportsRtl="true"

android:theme="@style/Theme.COEXP29">
<activity android:name=".MainActivity">
<intent-filter>
<action
android:name="android.intent.action.MAIN" />

<category
android:name="android.intent.category.LAUN
CHER" />
</intent-filter>
</activity>
</application>

</manifest>
XI. References / Suggestions for further Reading
1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com
XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1 Logic Formation 10%
.
2 Debugging ability 15%
.
3 Follow ethical practices 5%
.
Product related (15 Marks) 70%
4 Interactive GUI 20%
.
5 Answer to Practical related questions 20%
.
6 Expected Output 20%
.
7 Timely Submission 10%
.
Total (25 Marks) 100%

List of student Team Members


1 Heet Zatakia

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)
Practical No. 30: Develop a program to send and receive e-mail.

I. Practical Significance
To send email from your Android application, you have to write an Activity that needs
to launch an email client and send an email using your Android device. This practice
focuses on integrating the existing email clients in the new applications.

II. Relevant Program Outcomes (POs)


PO1- Basic knowledge
PO2- Discipline
knowledge
PO3- Experiments and
practice PO7- Ethics

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to use the existing email clients in any android applications.
2. Able to develop the application for sending the emails.

IV. Relevant Course Outcome(s)


1. Configure Android environment and development tools.
2. Develop rich user Interfaces by using layouts and controls.
3. Use User Interface components for android application development.

V. Practical Outcome (PrOs)


Develop a program to send and receive e-mail.

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


Intent Object - Action to send Email:
You will use ACTION_SEND action to launch an email client installed on your Android
device. Following is simple syntax to create an intent with ACTION_SEND action.
Intent emailIntent = new Intent(Intent.ACTION_SEND);

Intent Object – Data Type to send Email


To send an email you need to specify mailto: as URI using setData() method and data
type will be to text/plain using setType() method as follows:
emailIntent.setData(Uri.parse("mailto:"));
emailIntent.setType("text/plain");
VIII. Resources required(Additional)
Sr. Instrument Specificatio Quanti Remarks
No. /Object n ty
Android enabled 2 GB RAM 1 Data cable
1 smartphone / Android is
version supporting mandatory
emulator for
emulators

IX. Practical related Questions


Note: Below given are a few sample questions for reference. Teachers
must design more such questions to ensure the achievement of identified CO.
1. Why it becomes necessary to have an inbuilt email module in mobile applications.
2. List the extra fields that can be used in an application to send emails.

(Space for answers)

Ans 1) Before starting Email Activity, You must know Email functionality with
intent, Intent is carrying data from one component to another component with-in the
application or outside the application.
To send an email from your application, you don’t have to implement an email client
from the beginning, but you can use an existing one like the default Email app
provided from Android, Gmail, Outlook, K-9 Mail etc. For this purpose, we need to
write an Activity that launches an email client, using an implicit Intent with the right
action and data. In this example, we are going to send an email from our app by using
an Intent object that launches existing email clients.

Ans 2) Extra fields that can be used in an application to send emails are as follows:
EXTRA_EMAIL - It’s an array of email addresses
EXTRA_SUBJECT - The subject of the email that we want to send
EXTRA_TEXT - The body of the email
X. Exercise
Note: Faculty must ensure that every group of students use different input
value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to send email.

(Space for answers)

Ans1) 1. Activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="To:"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />

<EditText
android:id="@+id/edit_text_to"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Subject:"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />

<EditText
android:id="@+id/edit_text_subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailSubject" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Message:"
android:textAppearance="@style/TextAppearance.AppCompat.Large" />

<EditText
android:id="@+id/edit_text_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start|top"
android:lines="10" />

<Button
android:id="@+id/button_send"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="send" />

</LinearLayout>

2. MainActivity.java

package com.example.coexp30;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {


private EditText mEditTextTo,mEditTextSubject,mEditTextMessage;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mEditTextTo = findViewById(R.id.edit_text_to);
mEditTextSubject = findViewById(R.id.edit_text_subject);
mEditTextMessage = findViewById(R.id.edit_text_message);

Button buttonSend = findViewById(R.id.button_send);


buttonSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sendMail();
}
});
}
private void sendMail() {
String recipientList = mEditTextTo.getText().toString();
String[] recipients = recipientList.split(",");
String subject = mEditTextSubject.getText().toString();
String message = mEditTextMessage.getText().toString();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, recipients);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, message);
intent.setType("message/rfc822");
startActivity(Intent.createChooser(intent, "Choose an email client"));
}
}
XI. References / Suggestions for further Reading
1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1 Logic Formation 10%
.
2 Debugging ability 15%
.
3 Follow ethical practices 5%
.
Product related (15 Marks) 70%
4 Interactive GUI 20%
.
5 Answer to Practical related questions 20%
.
6 Expected Output 20%
.
7 Timely Submission 10%
.
Total (25 100%
Marks)

List of student Team Members


1 Heet Zatakia

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)
Practical No. 31: Deploy map-based application. Part I

I. Practical Significance
Android allows us to integrate google maps in our application. You can show any
location on the map, or can show different routes on the map. You can also customize
the map according to your choices.

II. Relevant Program Outcomes (POs)


PO1- Basic knowledge
PO2- Discipline
knowledge
PO3- Experiments and
practice PO4- Engineering
tools

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to integrate Maps in any application.
2. Demonstrate the benefits of Maps and its uses.

IV. Relevant Course Outcome(s)


1. Configure Android environment and development tools.
2. Develop rich user Interfaces by using layouts and controls.
3. Create an Android application using a database.
4. Publish Android applications.

V. Practical Outcome (PrOs)


Deploy map-based application. Part I

VI. Relevant Affective Domain related Outcomes


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


Add the map fragment into the xml layout file. Its syntax is given below –
<fragment
android:id="@+id/map
"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Add some permissions along with the Google Map
API key in the AndroidManifest.XML file. Its syntax is given
below:
<!--Permissions-->
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE
<uses-permission android:name="android.permission.INTERNET"
/>
<uses-permission
android:name="com.google.android.providers.gsf.permission.
READ_GSERVICES" />
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STO
RAGE" />

VIII. Resources required (Additional)


Sr. Instrument Specificatio Quantit Remarks
No. /Object n y
Android enabled 2 GB RAM 1 Data cable
1 smartphone / Android is
version supporting mandatory
emulator for
emulators

IX. Practical related Questions


Note: Below given are a few sample questions for reference. Teachers
must design more such questions to ensure the achievement of identified CO.
1. List the names of map types and write the syntax to change it.
2. Name the methods used to enable and disable zoom features.

(Space for answers)

Ans 1) The following map types are supported in Google Maps API:
1. ROADMAP (normal, default 2D map)
2. SATELLITE (photographic map)
3. HYBRID (photographic map + roads and city names)
4. TERRAIN (map with mountains, rivers, etc.)
The map type is specified either within the Map properties object, with the
mapTypeId property:
var mapOptions = {
center:new google.maps.LatLng(51.508742,-0.120850),
zoom:7,
mapTypeId: google.maps.MapTypeId.HYBRID
};
Or by calling the map's setMapTypeId() method:
map.setMapTypeId(google.maps.MapTypeId.HYBRID);

Ans 2) To enable or disable all interactive features, we use the interactivity() method.
Set true or false to the method depending if you'd like to enable the map interactivity
or disable it.
X. Exercise
Note: Faculty must ensure that every group of students use different input values.
(Use blank space for answers or attach more pages if needed)
1. Write a program to locate the user's current location.

(Space for answers)

Ans1) 1. activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns: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"
tools:context=".MainActivity">

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

2. build.gradle (:app)

plugins { buildTypes {
id 'com.android.application' release {
} minifyEnabled false
proguardFiles
android { getDefaultProguardFile('proguard-android-
compileSdkVersion 30 optimize.txt'), 'proguard-rules.pro'
buildToolsVersion "30.0.3" }
}
defaultConfig { compileOptions {
applicationId "com.example.coexp31" sourceCompatibility
minSdkVersion 17 JavaVersion.VERSION_1_8
targetSdkVersion 30 targetCompatibility
JavaVersion.VERSION_1_8
versionCode 1 }
versionName "1.0" }

testInstrumentationRunner dependencies {
"androidx.test.runner.AndroidJUnitRunner"
} implementation
'androidx.appcompat:appcompat:1.3.0' implementation
implementation 'com.google.android.gms:play-services-
'com.google.android.material:material:1.3.0' location:18.0.0'
implementation testImplementation 'junit:junit:4.+'
'androidx.constraintlayout:constraintlayout:2.0. androidTestImplementation
4' 'androidx.test.ext:junit:1.1.2'
implementation androidTestImplementation
'com.google.android.gms:play-services- 'androidx.test.espresso:espresso-core:3.3.0'
maps:17.0.1' }

3. strings.xml

<resources>
<string name="app_name">COEXP31</string>
<string name="map_key"
translatable="false">AIzaSyB_qsP8AOP_P0MdlPz-48TDaJYjTP3vbjo</string>
</resources>

4. MainActivity.java

package com.example.coexp31; ces;


import
import com.google.android.gms.maps.CameraUpdateF
androidx.appcompat.app.AppCompatActivity; actory;
import
import android.os.Bundle; com.google.android.gms.maps.GoogleMap;
import androidx.annotation.NonNull; import
import com.google.android.gms.maps.OnMapReadyCa
androidx.appcompat.app.AppCompatActivity; llback;
import androidx.core.app.ActivityCompat; import
import com.google.android.gms.maps.SupportMapFra
androidx.fragment.app.FragmentActivity; gment;
import
import android.Manifest; com.google.android.gms.maps.model.LatLng;
import android.content.pm.PackageManager; import
import android.location.Location; com.google.android.gms.maps.model.MarkerO
import android.os.Bundle; ptions;
import android.widget.Toast; import
com.google.android.gms.tasks.OnSuccessListen
er;
import import com.google.android.gms.tasks.Task;
com.google.android.gms.location.FusedLocatio
nProviderClient; public class MainActivity extends
import FragmentActivity implements
com.google.android.gms.location.LocationServi OnMapReadyCallback {
tLocation.getLatitude()+""+currentLocation.get
Location currentLocation; Longitude(),Toast.LENGTH_SHORT).show();
FusedLocationProviderClient SupportMapFragment
fusedLocationProviderClient; supportMapFragment=(SupportMapFragment)
getSupportFragmentManager().findFragmentBy
private static final int REQUEST_CODE =
101; Id(R.id.google_map);
// SupportMapFragment
@Override supportMapFragment = (SupportMapFragment)
protected void onCreate(Bundle getSupportFragmentManager().findFragmentBy
savedInstanceState) { Id(R.id.google_map);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); supportMapFragment.getMapAsync(MainActiv
ity.this);
}
fusedLocationProviderClient = }
LocationServices.getFusedLocationProviderCli });
ent(this);//CLIENT REGISTER
fetchLastLocation(); }
}
@Override
private void fetchLastLocation() { public void onMapReady(GoogleMap
if googleMap) {
(ActivityCompat.checkSelfPermission(this, LatLng latLng = new
Manifest.permission.ACCESS_FINE_LOCATI LatLng(currentLocation.getLatitude(),currentLo
ON) != cation.getLongitude());
PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this, MarkerOptions markerOptions = new
Manifest.permission.ACCESS_COARSE_LOCA MarkerOptions().position(latLng).title("I am
TION) !=
here");
PackageManager.PERMISSION_GRANTED) {

ActivityCompat.requestPermissions(this, new googleMap.animateCamera(CameraUpdateFact


String[]{Manifest.permission.ACCESS_FINE_ ory.newLatLng(latLng));
LOCATION}, REQUEST_CODE);
return; googleMap.animateCamera(CameraUpdateFact
ory.newLatLngZoom(latLng,5));
googleMap.addMarker(markerOptions);
}
}
Task<Location> task = @Override
fusedLocationProviderClient.getLastLocation(); public void onRequestPermissionsResult(int
task.addOnSuccessListener(new requestCode, @NonNull String[] permissions,
OnSuccessListener<Location>() { @NonNull int[] grantResults) {
@Override switch (requestCode){
public void onSuccess(Location case REQUEST_CODE:
location) { if(grantResults.length>0 &&
if (location != null){ grantResults[0] ==
PackageManager.PERMISSION_GRANTED){
currentLocation = location; fetchLastLocation();
Toast.makeText(getApplicationContext(),curren }
break; }
} }

5. AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.coexp31">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.COEXP31">

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/map_key"/>

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
</application>

</manifest>
ianistan Islamabad JAMMU AND
KASHMIR

Lahore,°

°UNJA9
Pakistan UTTARAKHAND
HAR’7ANA

New DeIN UTTAR


’ *RADESH
RAJASTHAN
Jaipur
Karach›

GUJARA+ Ahmedabad
India

Ur

Mumbai / AHARASHTFA

*ELANGANA
Hyderabad

ANOHRA
KAPNATAkA PRADESD

Bengaluru

KEPALA

Sri Lan

19.043085172.8572711

Google Google
XI. References / Suggestions for further Reading
1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1 Logic Formation 10%
.
2 Debugging ability 15%
.
3 Follow ethical practices 5%
.
Product related (15 Marks) 70%
4 Interactive GUI 20%
.
5 Answer to Practical related questions 20%
.
6 Expected Output 20%
.
7 Timely Submission 10%
.
Total (25 Marks) 100%

List of student Team Members


1 Heet Zatakia

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)
Practical No. 32: Deploy map-based application. Part II
I. Practical Significance
Android allows us to integrate google maps in our application. You can show any
location on the map, or can show different routes on the map. You can also customize
the map according to your choices.

II. Relevant Program Outcomes (POs)


PO1- Basic knowledge
PO2- Discipline
knowledge
PO3- Experiments and
practice PO4- Engineering
tools

III. Competency and Practical Skills


“Create simple Android applications.”
This practical is expected to develop the following skills
1. Able to integrate Maps in any application.
2. Demonstrate the benefits of Maps and its uses.

IV. Relevant Course Outcome(s)


1. Configure Android environment and development tools.
2. Develop rich user Interfaces by using layouts and controls.
3. Create an Android application using a database.
4. Publish Android applications.

V. Practical Outcome (PrOs)


Deploy map-based application. Part II

VI. Relevant Affective Domain Related Outcome(s)


1. Work collaboratively in team
2. Follow ethical Practices.

VII. Minimum Theoretical Background


Methods available in the Google Map class are given below.
1.addCircle(CircleOptions options) : This method add a circle to the map
2.addPolygon(PolygonOptions options) : This method add a polygon to the map
3.addTileOverlay(TileOverlayOptions options) : This method add tile overlay to the
map
4. animateCamera(CameraUpdate update) : This method Moves the map according to
the update with an animation
5. clear() : This method removes everything from the map
6. getMyLocation() : This method returns the currently displayed user location
7.moveCamera(CameraUpdate update) : This method repositions the
camera
according to the instructions defined in the update
8.setTrafficEnabled(boolean enabled) : This method Toggles the traffic layer on or off
9.snapshot(GoogleMap.SnapshotReadyCallback callback) : This method Takes a
snapshot of the map
10. stopAnimation() : This method stops the camera animation if there is one in
progress

VIII. Resources required (Additional)

Sr. Instrument Specificatio Quantit Remarks


No. /Object n y
Android enabled 2 GB RAM 1 Data cable
1 smartphone / Android is
version supporting mandatory
emulator for
emulators

IX. Practical related Questions


Note: Below given are a few sample questions for reference. Teachers
must design more such questions to ensure the achievement of identified CO.
1. Explain the ways to add Markers on the Google Map.
2. Write the syntax for the method which is used to add a compass in Google Map.

(Space for answers)


Ans 1) For adding a custom marker to Google Maps navigate to the app > res >
drawable > Right-Click on it > New > Vector Assets and select the icon which we
have to show on your Map. You can change the color according to our requirements.
After creating this icon now we will move towards adding this marker to our Map.

Ans 2) The Maps API provides a compass graphic which appears in the top left corner
of the map under certain circumstances. The compass will only ever appear when the
camera is oriented such that it has a non-zero bearing or non-zero tilt. When the user
clicks on the compass, the camera animates back to a position with bearing and tilt of
zero (the default orientation) and the compass fades away shortly afterwards. You can
disable the compass appearing altogether by calling
UiSettings.setCompassEnabled(boolean). However, you cannot force the compass
to always be shown.

X. Exercise
Note: Faculty must ensure that every group of students use different input
value.
(Use blank space for answers or attach more pages if needed)
1. Write a program to draw a route between two locations.

(Space for answers)


Ans1) 1. activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<androidx.constraintlayout.widget.ConstraintLayout
xmlns: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:orientation="vertical"
android:padding="16dp"
android:gravity="center_horizontal"
tools:context=".MainActivity">
<EditText
android:id="@+id/et_source"
android:layout_width="317dp"
android:layout_height="56dp"
android:layout_marginTop="220dp"
android:background="@android:drawable/editbox_background"
android:fontFamily="@font/poppins_medium"
android:hint="Enter Source Location"
android:padding="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/et_destination"
android:layout_width="317dp"
android:layout_height="52dp"
android:layout_marginTop="36dp"
android:background="@android:drawable/editbox_background"
android:fontFamily="@font/poppins_medium"
android:hint="Enter Destination Location"
android:padding="12dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/et_source" />
<Button
android:id="@+id/bt_track"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="56dp"
android:fontFamily="@font/poppins_medium"
android:text="Display Location"
app:backgroundTint="#3F51B5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/et_destination" />
</androidx.constraintlayout.widget.ConstraintLayout>

2. MainActivity.java

package com.example.coexp32;
import androidx.appcompat.app.AppCompatActivity;

import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Display;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
EditText etSource,etDestination;
Button btTrack;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etSource = findViewById(R.id.et_source);
etDestination = findViewById(R.id.et_destination);
btTrack = findViewById(R.id.bt_track);
btTrack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String sSource = etSource.getText().toString().trim();
String sDestination = etDestination.getText().toString().trim();
if(sSource.equals("") && sDestination.equals("")){
Toast.makeText(MainActivity.this, "Enter both location",
Toast.LENGTH_SHORT).show();
}else{
DisplayTrack(sSource,sDestination); }}}); }
private void DisplayTrack(String sSource, String sDestination) {
try{

Uri uri = Uri.parse("https://www.google.co.in/maps/dir/" + sSource + "/"


+ sDestination);
Intent intent= new Intent(Intent.ACTION_VIEW,uri);
intent.setPackage("com.google.android.apps.maps");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}catch (ActivityNotFoundException e){
Uri uri =
Uri.parse("https://play.google.com/store/apps/details?id=com.google.android.apps.maps");
Intent intent= new Intent(Intent.ACTION_VIEW,uri);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}}}
XI. References / Suggestions for further Reading
1. https://www.tutorialspoint.com/android
2. https://stuff.mit.edu
3. https://www.tutorialspoint.com/android/android_advanced_tutorial.pdf
4. https://developer.android.com

XII. Assessment Scheme

Performance indicators Weightage


Process related (10 Marks) 30%
1 Logic Formation 10%
.
2 Debugging ability 15%
.
3 Follow ethical practices 5%
.
Product related (15 Marks) 70%
4 Interactive GUI 20%
.
5 Answer to Practical related questions 20%
.
6 Expected Output 20%
.
7 Timely Submission 10%
.
Total (25 Marks) 100%

List of student Team Members


1 Heet Zatakia

Dated signature of
Marks Obtained
Teacher
Process Product Total
Related(10) Related(15) (25)

You might also like