0% found this document useful (0 votes)
85 views59 pages

Mobile Application Development Summer 2024 Model Answer

The document provides guidelines for examiners assessing answers in Mobile Application Development, emphasizing the importance of understanding over verbatim responses. It includes instructions on evaluating various components of Android, such as its operating system features, emulator roles, UI design components, and security models. Additionally, it outlines the Android activity lifecycle and installation steps for Android Studio, highlighting key concepts and comparisons relevant to the subject matter.

Uploaded by

pandablue901
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views59 pages

Mobile Application Development Summer 2024 Model Answer

The document provides guidelines for examiners assessing answers in Mobile Application Development, emphasizing the importance of understanding over verbatim responses. It includes instructions on evaluating various components of Android, such as its operating system features, emulator roles, UI design components, and security models. Additionally, it outlines the Android activity lifecycle and installation steps for Android Studio, highlighting key concepts and comparisons relevant to the subject matter.

Uploaded by

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

STATE BOARD OF TECI-NICAL EDUCATION

(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

22617
Subject Name: Mobile Application Development Subject Code:
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 shéåld not be given more Importance (Not applicable
for subject English and Communication Skills.

4) While assessing figures, examiner may give credit for principal compo ents indicated in the figure. The figures d
awn by candidate and model answer may vary. The examiner may give credit for any equivalent figure drawn
Q. Marking
No Scheme

1 Attempt any FIVE of the following: IOM


a) List any four features of android operating system. 2M
An Features of Android Operating System: Any 4 one
si l)Storage for 172 M

2)Multitasking isccir.cc
3)Web Browser
4)Open Source
5)Accessibility
6)Media Suppolt
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.
5) Credits may begiven stepwise for numerical problems. InsomÅcaseS;the assumed constantualue 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.

Page No: 1 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
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 shall consider the same and assess the answer based on matching of concepts with mode

answer.

Page No: | 34
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

Page No: 3
2
| 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

An Android emulator is a tool that creates virtual Android devices on your computer. The Conect
emulator lets you prototype, developlånd test Android applications without uslpg a definition
physical device 2M
c) List various components of android UI design. 2M
An Components of android UI design: One for h
S

l)
views
4)activity
d) List any two attributes of Toggle Button. 2M
An l. android:textOff any 2
2. android:textOn attributes ,
s one
attribute

fo!9ne
M
3. android:id
4. android:åecked
5. androld:gravity
e Define service in android operating system. 2M
An A service is an application component which runs without direct interaction with the user Conect
s in the background. Services are used for repetitive and potentially long running definition
operations, i.e., Intemet downloads, checking for new data, data processing, updating 2M
content providers and the like.

f) 2M
Explain two methods of Google Map.
An getMyLocation(): This method retums the currently displayed user location. One
s method for
moveCamera(CameraUpdate update): This method reposition the camera according to the
instructions defined in the update.
g) Write down syntax to create an intent and start another activity. 2M

Page No: | 34
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
An Intent i = new Intent(this, ActivityTwo.class); //create intent create
s startActivity(i); //start activity intent for I
M and
start
activity 1

Attempt any THREE of the following: 12 M


a) Explain need of android.
An Android is a new generation mobile OS which runs on Linux kemel. There are some Any four
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, 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, Tum ON/OFF Bluetooth, Tum ON/OFF WiFi,
Ttun ON/OFF mobile network, Tum 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 FJakh support, so we cannot watch
Youtubéyideos or any related contents, it is not flexiblebut monopolistic.

Open to Carrier: If we know Java pr.oepmming language then we are open to dY01d
world.

5. Market: Android OS has an android market. The android apps are free an
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.

Page No: 5 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

10. Endless Personalization: The Android cell phone allows to configuration


their mobile to look and behave exactl like the want.
b) Compare JVM and DVM. (any four points) 4M
Any four
DVM points 4
M, 1 for
on poin )

JVM supports multiple operatin DVM supports only Android Operating


systems. System.

JVM fonns separate classes in separate DVM fonns multiple class in .dex byte
code file.
.class byte code files.

It is based on stack based virtual It is based on Register based virtual


machine architecture. machine architecture.

JVM runs on more memory. DVM runs on less memory.

The executable fonnat of JVM is JAR. The executable format of DVM is APV

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.

Page No: | 34
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
An Android i multi-process system, in lanatio
which each ap lication (and pmts of the
system) runs in its own process.

yo@security between applications and the sykßiii is enforced at the process level throu yon•ec

tandard Linux facilities, such as user an oup IDs that are assigned to applications
s
Additional finer-grained security fea are provided through a "permission" mechanism
that enforces restrictions on the speclf1C operations that a patticular process canperfonn,
and per-URI permissions for granting aålhoc access to specific pieces of data.

The Android security model is plimarily based on a sandbox and pennission 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
pennanent 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: 7 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

It is mandatory for an application to F all the resources it will Access dtlling installation.

The purpose of a permission is to p otect the privacy of an Android user. Andro•d apps
must request pennission to access sensitive user data (such as contacts and SMS), as well
as certain system features (such as camera and intemet).

Pennissions are divided into several protection levels. The protection level affects
whether rtmtime pennission requests are required.

Resources

Android introduced shared user ID & pennission 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.

Page No: 8 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

Page No: 9 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
Diagram
2M,
Explanati

onDestroy()

onCrea (): alled then the acfivity is creafed.Gse alize e 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: 10 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

example you unregister listeners, inteyt 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 infonnation 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 identifr activities that are no
longer in use, allowing the OS to reclaim memory and resources. Fig. illustrates the
states an activity can go through, dilling its lifetime:
These states are often broken into three main teams as follows:
1. Active or Running:
Activities are thought of active or nmning if they're within the foreground, additionally
refen•ed 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 theUI to become unresponsive.

2. Paus€g.
Whgii the device goes to sleep, or an activity continues to be visible but partially hidden
b ew, non-full-sized or clear activity, the(gctWity is taken into account paused. Paus&d
vities are still alive, that is, they state and member information, and,stayv
attached to the window manager. Thiscan be thought of to be the second highest priofity
activity within the android Activity—tack and, as such, can solely be OS if
killing this activity can satisfy the4esource 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 dilling this state initial to satisfy the
resource needs of higher riori activitiese co

Page No: 11 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

3. Attempt any THREE of the following: 12 M


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

An Steps to install Android studio and SDK Android


S studio
Pre-Installation Check List installation
I. 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. SDK M
2. Uninstal older version(s) of "Android Studio" and " droid SDK", if any.

Page No: 12 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

We need to install two packages:


1. Android Studio (IDE), which isag Integrated Development Environment (ID )
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 Tenns 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 tenns and conditions, select the I have
read and agree with the above tenns 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 $6inputer, click Yes to confinn the installatioiv
d) Click Ngxt to start the installation.
e) Acceptfhe default installation settings for all
f) 9icKfinish when installation is done:

tailing Android SDK ithin Android


Studio, you can install!he
1. Click Tools > SDK Manager.
2. In the SDK Platfonns tab, selecesndroid Timmisu Preview.
3. In the SDK Tools tab, select Android SDK Build.
4. Click 0K to install the SDK. co
b) Explain scrollview with its attributes and with suitable example.

Page No: 13 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

An s Explain:
1M
•butes:
S
crollView
Example :
Attributes of ScrollView 2M

• - Defines whether the scrollview should stretch its content


to fill the viewport.

• android:scrollbars - scrollbars attlibute is used to show the scrollbars in horizontal


or vertical direction

• android:layout_width — Define the width

• android:layout_height — Define height

• andrt@l.•id — Define id

Page No: 14 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

Example •
<?xml
version="l.0"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"

android:paddingRight=" 1

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

<Button
android:layout_width="match_parent"

android:text="Button 3"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button 4"/>

O
</
LinearLayout>
</ScrollView>
</LinearLayout> co
c) Write significance of SQLite database in android.
S Any 4
• SQLite is an open-source relational database i.e. used to perfonn database
points :

Page No: | 34
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

operations on android devices such as st01ing, manipulating or retrieving


persistent data from the database.

• It is embedded in android bydefault. So, there is no need to perfonn any database


setup or administration task

• SQLite is one way of storin app data. It is very lightweight database tha gomes co
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 ovenides the onCreate() and onUpgrade() call-back
methods.

• SQLiteDatabase class contains methods to be performed on sqlite database such


as create, update, delete, select etc.

g, an insert data into the SQLite databas epassing

Page No: 16 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

ContentValues to insert() method,e

• O
ln android, we can read the data frolfgllé SQLite database using the query()
method in android appOcations.
We can update the data in the SQLit database using an update() method in ancimid
applications.

d) Explain importance or use of developer console.

An Google Play Developer Console is the platfonn that Google provides for Google Play and Any 4
Android developers to publish their apps. O points :
s
• The Google Play Developer
console allows app developers and marketers to better understand how their apps
are perfonning in tenns 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 perfonnance 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 me.

Page No: | 34
4. Attempt any THREE of the following: 12M
a) Describe linear layout and frame layout with example.
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
An Linear Layout Linear
(ISO/IEC 7001 - 2013 Certified)
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 2M
column(vertically)
or a single row(horizontally).
Frame
Whether all the children will be an-anged horizontally or vertically depends upon the value layout : 2
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"

co

?uttål

android:layout_width="270dp" android:layout_height="wrap_ Ontent" android:text="Button

1 "/>

android:id="@+idibtnStopService" android:layout_width="270dp"

android:layout_height="wrap_content" android:text="Button 2"/>

</LinearLayout>

2. Frame Layout

FrameLayout@s designed to block out an area on thecreen to display a single item. Generall
OFrameLayout should be used to hold a single child view, because it can be difficult

Page No: 18 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

to organize child views in a way tha ' ycalable to different screen sizes without
thechildren overlapping each other.

We can add multiple children to a FmmeLayout and control their position within the
FrameLayout by assigning gravity to each child, using the android:layout_gravity
attribute.

Example:

<FrameLayout

xmlns:android="httpi//schemas.android.conüapk/res/android"

xmlns:app="http://schemas.android.eom/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:layout_width="200dp android:layout_height="200dp"

Page No: | 34
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

android:

<TextView

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_gravity=

</Frame

Page No: 20 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

b) Write a program to create first display screen of any search engine using auto gomplete 4M
text view.
An <RelativeLayout Xml file:
xmlns:android="http://schemas.android.com/apk/res/android"
1M
Java file: 3
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:layout_gravity="center">

<AutoCompleteTextView
android:id="@+id/txt"

</RelativeLayout>

import android.widget.ArrayAdapter; import


android.widget.Button; import
android.widget.EditText; import
android.widget.TextView; import

Page No: | 34
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

android.widget.Toast; import
androidx.appcompat.app.AppCompatActivity;

import android.view.View; import


android.widget.AutoCompleteTextView; impolt
android.widget.Button;

public class MainActivity extends AppCompatActivity

String[]
"orange",
AutoCompleteTextView txt;

@Oven-ide protected void onCreate(Bundle


savedInstanceState) {

Array
Adapter adp = new An-a Adapter(this, android.R.layout.simple_dropdown_item_l line, fruits);
txt.setThreshold(l);

Page No: 22 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

illG0fiir.ccIJT
c)
:,
What is fragment? Explain with example.

Define
• Android Fragment is the part of activity, it is also known as sub-activity. There can be
Fragment
more than one fragment in an activity. •
2M
• Fragments represent multiple screen inside one activity. Example
:
2M

Page No: | 34
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

• We can create Fragments by extending Fragment class or by inserting a gment into


our Activity layout by declaring the Fragment in the activity's layou 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
sepamtely. With the
help of Fragment's we can divide the screens in different parts and
controls different pansseparately.

Example:
activity_main.xml:

<?xml version=" I .0" encoding="utf-8"?>


<LinearLa ooxmlns:android="http://schemas.android.coin/apk/res/android"
xn}lnsåools="http://schemas.android.com/too

tools:context=".MainActivity">
xmlns:app="http://schemas.android.com/apk/respaåib"

<fmgment android:id="@+id/Frag1 "


android:layout_width="match_parent"

android:layout_height="400dp"
android:name="com.example.al_libaansapp"/>
<fragment
android:
android: layout_width="match_parent"
android:layout_height="400dp"
android:name="com.example.al_libaansapp" </LinearLayout>

- Fragmentl .xml:

Page No: 24 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

<?xml version="l .0" encoding="utf-8"?>

<FrameLa ou xmlns:android="http://schemas.android.com/apk/res/android"

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

android:layout_width="match_pareut'
android:layout_height="match_par
nt"
android:background="@color/black"
tools: context—" .Fragment1 ">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"

android:textStyle="bold" />

</FrameLayout>

- Fragment2.xml:

<FrameLayouts

Page No: | 34
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"

android:text="Fragment 2"
android:textSize="40dp"
android:textStyle="bold"

</FrameLayout>

d) Describe types of permissions used while developing android application.

Types of permissions Each type :


1M
1. Install-time permissions co

• Install-time pennissions give your app limited access to restricted data, and they
allow your app to perfonn restricted actions that minimally affect the system or
other apps.

o o
• When you declare install-time pennissions 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 pennissions,

Nonnal pennissions and Signature permissions.

Page No: 26 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

a) Normal permissions

a signatuyp

• These pennissions allow access to data and actions that extend beyond your app's

ermission that another app has defined(4n if the


two apps are signed by the same certificate, then the system grants the
pennission to the first app at install time. Otherwise, that first app cannot be
granted the pennission.

2. Runtime permissions
• Runtime permissions, also known as dangerous permissions, give
your app additional access to restricted data, and they allow your app to perfonn
restricted Lactions that more substantially affect the system and other apps.

• Many mntime permissions access private user data, a special type of restricted
data that includes potentially sensitive infonnation. Examples of private user data
include location and contact infonnation.

• The system assigns the "dangerous" protection level to nultime pennissions.


3. Special permissions

• Speciå) pennissions conespond to particular app bperations.

Page No: | 34
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

• Only the platfonn and OEM an define special permissions.


Additionally, the platform and O s usually define special permissions when ey want to
protect access to particularly powerful actions, such as drawing over other apps.

e) Develop a program to send an SMS. 4M

Page No: 28 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

An AndroidManifest.xml Xml file:


2M
Java File •

encoding—'hitfL8". 2M
co
<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/textView"

dp"

android:layout_mafgmEnd="268dp"

an&oiååext4ör8LI'

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"/>

<TextView
android:id="@+id/textView2"

android:la

Page No: 29 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

Page No: 30 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

android:layout_height="43dp"

android:layout_marginEnd="276dp

android: 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"

a
ndroid:

<EditText
android:id="@+id/etmsg"

android: 504dp"

android:inputType="textPersonName"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constmintEnd_toEndOf="parent" />

<Button

Page No: 31 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

Page No: 32 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

android:id="@+id/btnSms"

android:layout_width="wrap_conte t"

android:layout_height="wrap_content"

android : 156dp"
android:layout_marginBottom="400dp"

app:layout_constraintEnd_toEndOf="parent" />

</androidx.constraintlayout. widget.ConstraintLayout>

MainActivity.java public class MainActivity extends

AppCompatActivity

protectedvoid onCreate(BundlesavedInstanceState)

super.onCreate(savedInstanceState);

et2=findViewById(R.id.etmsg);

if(ContextCompat.checkSelfPermissionOIainActivity.this,Manifest.permission.SEND SMS)!

PackageManager.PERMISSION_GRANTED)

ActivityCompat.requestPennissions(MainActivity.this,new
Page No: 33 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

Page No: 34 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

String[] {Manifest.pennission. , 100);

bl.setOnClickListener(new View.OnClickListene1() {
@Ove1Tide public void
onClick(View v) {

CVLJ
String msg=et2.getText().toString();

SmsManager smsManager= SmsManager.getDefault();

smsManager.sendTextMessage(phno,null,msg,null,null);
Toast.makeText(MainActivity.this,"Sms sent successfully",

hjsocir.ccj„
Page No: 35 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
Attempt any TWO of the following: 12M

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 xml file-
required. In java file all imports are not expected. Different relevant 2M
logic/code can be considered.) activity main.xml java code-

<?xml version="l .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"

oid:layout
tools:context=".MainActivity">

<EditText
android:layout_width="wrap_content"
android:layout_height=" wrap_content "
android:hint="Enter a number"

"@+id/number"

Page No: 36 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

<Button android:layout_width="
wrap_content " android:

layout_height="wrap_content"
android:id="@+id/btnl"
android:layout_below="@id/number"
android:textSize="20dp"
android:text="Calculate Factorial"

<TextView
android:layout_width="wrap_content"

Page No: 37 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
android:layout_height="wrap_ ontent" android:id="@+id/tv"
co

android:textSize="20dp"/>
</RelativeLayout>

MainActivity.java
-packagejeoni:examplé.

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle; import android-view.View;
import android.widget.Button;

Button btnl;
TextView tv;

int num;

int
factorajcocir
Page No: 38 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

String
@Ove1Tide protected void onCreate(Bundle
savedInstanceState) { super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
number=(EditText)findViewById(R.id.number); btnl— on)
findViewById(R.id. btnl);

Page No: 39 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
tv=(TextView)findViewById .id.tv

btnl .setOnClickListener(new View.OnClickListene1() {


@Ove1Tide public void
onClick(View v) {

factorial(num);

factor = factor * i;

s=

"Factorial of Number is tv.setText(s);

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


An (Note: Consider the appropriate XML file. All attributes are not required. XM
In java file all imports are not expected. Different relevant logic/code can be 2
considered.) Ja
cod

Page No: 40 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

Page No: 41 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

activity_main.xml
<?xml version="l .0" encoding="u 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"

an
droidiörieiitatibh=åfiorizonta tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"

android:layout_height="wrap_content"
android:tfittåCAMERA"

android:id="@+id/image"

Page No: 42 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text"

android:src="@drawable/rose"/>
<Button android:id="@+id/photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

Page No: 43 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

co
android:layout_marginTop="30dp

PHOTO"
</RelativeLayout>

MainActivity.java
-packagegconfexampl&ifcdi€;

import androidx.appcompat.app.AppCompatActivity;
import android.content.lntent; import
android.graphics.Bitmap; import android.os.Bundle;
import android.provider.MediaStore;

impolt .view.View;

aoid.widget.Button;
ii@01t android.widget.ImageView;

ublic Clåss MainActivity extends Ap

Button bl ;
ImageView imageView;

int
@Ovenide protected void onCreate(Bundle savedInstanceState)
{ super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); b 1=findViewById(R.id.photo);
imageView=findViewById(R.id.image); b I. setOnClickListener(new

Page No: 44 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

View.OnClickListener()
@Ovenide publiexoid onClick(View v)
Intent i=new Intent(MediaStore.ACTION IMAGE CAPTURE);

@Ovenide protected void onActivityResult(int requestCode, int resultCode, @Nullable


Intent data) { super.onActivityResult(requestCode, resultCode, data);
if REQUEST) { Bitmap image= (Bitmap)
data.getExtras().get("data"); imageView set geBitmap(image); } } }

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
<?xml version=" I .0" encoding="utf-8"?>
5M
<RelativeLayout
xmlns xmlns:android="http://schemas.android.com/apk/res/android"
:app="http://schemas.android.com/apk/res-auto"

".MainActivity">
tools <fragment android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/google_map"
android:name="com.google.android.gms.maps.Supp01tMapFragment" />
</RelativeLayout>

MainAct .Java

co

packageæom.example.location; imOV1t
androidx.annotation.NonNull; npolt
androidx.appcompat.app.AppCompa port androidx.core.
app.ActivityCompåt; import androidx.fragment.

Page No: 45 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

app.FragmeutÄctivity; import android.Manifest; impolt


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.CameraUpdateFaq@éty•, impolt
com.google.android.gms.maps.GoogleMap; import
com.google.android.gms.maps.OnMapReadyCallba@E; import
com.google.android.gms.maps.SupportMapFragment; impolt
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 cun•entlocation;
FusedLoeationProviderClient fusedLocationProvide1C1ient;

Page No: 46 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

private static final int = 101; @Ovenide protected void


onCreate(Bundle savedInstanceState) co
{ super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);
fusedLocationProvide1Client = LocationSewices.
getFusedLocationProviderClient(this) ; fetchLastLocation();

private void fetchLastLocation() { if


(ActivityCompat.checkSelfPennission(this,
Manifest.pemission.ACCESS FINE
LOCATION) ActivityCompat.checkSe1fPermission
PackageManager.PERMISSION_GRANTED
(this, ManifestpennissiomACCESS COARSE LOCATION)
PackageManager.PERMISSION_GRANTED)
{ ActivityCompat.requestPennissions(this,new

retum;

Task<Location> task = fusedLocationProviderClient.getLastLocation();


task.addOnSuccessListener(new OnSuccessListener<Location>() {

p);
supportMapFragment.getMapAsync(MainActivity.this);
public

void onMapReady(@NonNull GoogleMap googleMap) {


LatLng latLng=new
LatLng(cun•entlocation.getLatitude(),currentlocation.getLongitude());
MarkerOptions markerOptions=new MarkerOptions().position(latLng)
.title("l am Here");
googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng,5));
googleMap.addMarke1(marke10ptions);

@Ove1Tide public void onRequestPennissionsResult(int requestCode, @NonNull

Page No: 47 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

String[] pennissions, @NonNull int[] grantResults) {

super. onRequestPennissionsResult(requestCode, pennisslons, gmntResults);

switch •e uestCode

Page No: 48 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

case REQUEST CODE:


if (grantResults.length > 0 &&
grantResults[O]
PackageManager.PERMISSION_GRANTED)
{ fetchLastLocation(); break;

6. 12M
Attempt any TWO of the following:
a) Write a program to display the list of sensors supported by device. 6M

Page No: 49 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
An (Note: Consider the appropriate XML file. All attributes are not required. In java Xml file2M
S file all imports are not expected. Different relevant logic/code can be considered.)
Java code-

activity_main.xml

<?xml versiou=" 1.0" encoding="UTF-8"?>


co
<LinearLayout
an id:layout_height="match_parent"-cir-co android;ßaddingR1 I Odp"
droid:layout_width="match_parent"

xmlns:android="http://schemas.andrm
<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.sup1)01t.v7 .app.AppCompatActivity;
import android.os.Bundle; import
android.content.Context; import android-
hardware.Sensor; import
android.hardware.SensorManager; im It
android.view.View•

Page No: 50 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
import android.widget.TextView; import java.util.List;
public class MainActivity extends ppCompatActivity
{ private SensorManager mgr; private TextView txtList;
@Ovenide protected void onCreate(Bundle savedInstanceState) { super.
onCreate(savedInstanceState); setContentView(R.layout.activity_main);
mgr = 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


(Note: Consider (Fl file-
Differend 2M
Java
covity_main.xml
code-

An
<?xml version=" 1.0" <RelativeLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"> <EditText
O android:id="@+id/editTextl"

android:layout_width="wrap_content"
android:layout_height="wrap_content'
android:layout_alignParentTop="tme"
android:layout_alignParentRight="true"
android:layout_marginTop=" 18dp"
android:layout_marginRight="22dp" /> <EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"

Page No: 51 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
android:layout_height="wrap_content"
android:layout_below="@+id/editTextl"
android:layout_alignLeft="@+id/editTextl "
android:la out mar inTo ="20 " />

Page No: 52 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
<EditText android:id="@+id/editText3"
android:layout_width="wrap_content"
co
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/editTextl
"@+id/editTextl
android:layout_alignParentLeft="frue"
android:text="Send To:"

<TextView android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:layouf_alignBottom="@+id/editText2"
"

android:text="Email Body:"

android:id="@+id/button"

android:layout_alignLeft="@+id/editText3"

android:layout_marginLeft="76dp"
android:layout_marginTop="20dp"
android:text="Send email! !" />
</RelativeLayout>

MainActivity.java package
com.example.email;

im It android.content.lntent•

Page No: 53 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 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;
@Ove1Tide

protected void onCreate(Bundle


savedInstanceState) { super.
onCreate(savedInstanceState);

setContentView(R.layout.activity_main); // Getting instance of


edittext and button sendto = findViewById(R.id.editTextl);
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();

// defineytent object with action attlibute as ACTIC) _SEND


Intent intent = new Intent(Intent.ACTION SEND);
/hådd three fields to intent using putExtra TuychiOn
tént.putExtra(1ntent.EXTRA EMAIL,
mtent.putExtra(Intent.EXTRA SUBJECT, emailsubject); ¯
intent.putExtra(Intent.EXTRA TEX!, emailbody); // set
type of intent intent.
// startActivity with intent with chooser as Email client using createChooser fmction
stattActivity(Intent.createChooser(intent, "Choose an Email client :

O
co
c) Write a program to show five checkboxes and total selected checkboxes using linear la 6M
out.

Page No: 54 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
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="l .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"

<TextView

Page No: 55 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
android:layout_width="match_parent'&
android:layout_height="wrap_content" co
android:text="Hobbies" android:iV'@+id/tl"

<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"

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:te —
'Cycling

android:layout_width="wrap_conte»t
android:layout_height="wrap_content"
android:id="@+id/c5"
android:text="Football "

<Button

android:layout width="wrap_content"

Page No: 56 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
android:layout : height="wrap_content"-evcir.cc
android:text="Submit"
android:id="@+id/bl

</LinearLayout>

MainActivity.java

package com.example.checkbox; import


androidx.appcompat.app.AppCompatActivity;
import java.lang.StringBuffer; import
android.os.Bundle; import android.view.View;

im It android.wid et.Button•

Page No: 57 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
import android.widget.CheckBox; import
android.widget.Toast; public class MainActivity
extends AppCompatActivity { Button bl ;
CheckBox
String s; protected void onCreate(Bundle
savedInstanceState)
{ super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main); s ="Your
Hobbies are:- ", b 1=(Button) findViewById(R.id. bl
); cl =(CheckBox) findViewById(R.id.cl);
c2=(CheckBox) findViewById(R.id.c2);
findViewBy1d(R.id.c3);
c4=(CheckBox) findViewById(R.id.c4);
c5=(CheckBox) findViewById(R.id.c5);
bl.setOnClickListener(new View.OnClickListene1()
{ public void onClick(View v) { if(cl .isChecked())

if(c4.isChecked())

s= s +
Toast.makeText(getApplicationContext(),s,Toast.LENGTH

if(c5.isChecked())

Page No: 58 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)

show();

Page No: 59 | 59

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