0% found this document useful (0 votes)
100 views49 pages

Mad 22617 Winter 2023 Model Answer

This document is a model answer paper for the Mobile Application Development course (Subject Code: 22617) for the Winter 2023 examination. It provides guidelines for examiners on assessing student answers, including the importance of understanding over exact wording, and outlines various questions related to Android application development, including tools, concepts, and programming tasks. The document also includes specific answers and marking schemes for the questions posed.

Uploaded by

mr.ompawar9834
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)
100 views49 pages

Mad 22617 Winter 2023 Model Answer

This document is a model answer paper for the Mobile Application Development course (Subject Code: 22617) for the Winter 2023 examination. It provides guidelines for examiners on assessing student answers, including the importance of understanding over exact wording, and outlines various questions related to Android application development, including tools, concepts, and programming tasks. The document also includes specific answers and marking schemes for the questions posed.

Uploaded by

mr.ompawar9834
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)
lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)


lOMoARcPSD|31631162

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 Vikram Nimbalkar (nimbalkarvikram966@gmail.com)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy