Mobile Application Development Summer 2024 Model Answer
Mobile Application Development Summer 2024 Model Answer
(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
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
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.
8. Google Integration: The Android has inbuilt google support. For examle,
Google Map, G-Mail etc.
Page No: 5 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
JVM fonns separate classes in separate DVM fonns multiple class in .dex byte
code file.
.class byte code files.
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.
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.
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.
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.
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.
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)
Page No: 12 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
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
• 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)
• SQLite is one way of storin app data. It is very lightweight database tha gomes co
with Android OS.
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.
Page No: 16 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
• 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.
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
1 "/>
android:id="@+idibtnStopService" android:layout_width="270dp"
</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>
Page No: | 34
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
android.widget.Toast; import
androidx.appcompat.app.AppCompatActivity;
String[]
"orange",
AutoCompleteTextView txt;
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)
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:
tools:context=".MainActivity">
xmlns:app="http://schemas.android.com/apk/respaåib"
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)
<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>
• 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.
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
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.
Page No: | 34
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
Page No: 28 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
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" />
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>
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)
bl.setOnClickListener(new View.OnClickListene1() {
@Ove1Tide public void
onClick(View v) {
CVLJ
String msg=et2.getText().toString();
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-
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
factorial(num);
factor = factor * i;
s=
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;
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);
".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)
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)
retum;
p);
supportMapFragment.getMapAsync(MainActivity.this);
public
Page No: 47 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
switch •e uestCode
Page No: 48 | 59
BLXKXRASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC 7001 - 2013 Certified)
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
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);
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)
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
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