Mad 22617 Sample Papers
Mad 22617 Sample Papers
Mad 22617 Sample Papers
Page No: 1 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Dalvik Virtual Machine is a register-based machine that compiles byte code to get dex (Correct
code and that ensures that a device can run multiple instances efficiently. definition
2 M)
c) List any four folders from directory structure of Android project and 2M
elaborate in one line.
Ans Folders from directory structure: (List of
1)app: The App folder contains three subfolders (manifests, java and res) that make up names of any
our application. four folders :
They are divided so that it should be fairly easy to determine which resources go in which 1 M and
folder. elaboration
2)Manifest: This is where we would put our manifest files. Most Android apps have in one line
single manifest file. But an app may have several manifest files due to application
:1 M)
versioning, or for supporting specific hardware.
3)Java: This is the folder in our project where we will be storing all of the source code
files written in Java programming language.
4)res: It contains folders that help us to separate and sort the resources of our application.
Resources
basically mean all the needed files except the source code.
5)drawable: The drawable folder contains graphics that can be drawn to the screen.
6)layout: The layout folder contains XML files used for your layouts. These file are used
to set up the layout for your Activity and is used for basic alignment of your layouts,
components, widgets, and similar
resources that are used for the UI of your application.
7)mipmap : The mipmap folder contains the launcher icon files for the app. A launcher
icon is a graphic that
represents your app to users.
8)values: The values folder contains XML files that contain simple values, such as
strings, integers, and colors.
The values folder is used to keep track of the values we will be using in our application.
Page No: 2 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans (2 M for
correct
diagram)
Ans a) Built in Zoom control in Google map can be displayed with : Correct
Syntax : 2
UiSettings.setZoomControlsEnabled(true); M)
OR
b) In case, while display Google map by intent, default zoom level can be given in
the form of data as
geo:latitude,longitude?z=zoom
where lat and lag are for location and zoom level is to set initial zoom level which
Page No: 3 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
ranges from 0 to 21.
OR
3) AudioManager
Page No: 4 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Diagram: 2M
Explanation:
2M
1. Applications:
• The top layer of android architecture is Applications. The native and third party
applications like Contacts, Email, Music, Gallery, Clock, Games, etc. whatever we will
build those will be installed on this layer only.
• The application layer runs within the Android run time using the classes and services
made available from the application framework.
2. Application Framework:
• The Application Framework provides the classes used to create an Android application.
It also provides a generic abstraction for hardware access and manages the user interface
Page No: 5 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
and application resources.
• It basically provides the services through which we can create the particular class and
make that class helpful for the Applications creation.
• The application framework includes services like telephony service, location services,
notification. manager, NFC service, view system, etc. which we can use for application
development as per our requirements.
3. Android Runtime:
• The Android run time is the engine that powers our applications along with the libraries
and it forms the basis for the application framework.
(i) Dalvik Virtual Machine (DVM) is a register-based virtual machine like Java Virtual
Machine (JVM).
It is specially designed and optimized for android to ensure that a device can run multiple
instances efficiently. It relies on the Linux kernel for threading and low-level memory
management.
(ii) The core libraries in android runtime will enable us to implement an android
applications using standard JAVA programming language.
4. Platform Libraries:
• The Platform Libraries includes various C/C++ core libraries and Java based libraries
such as SSL, libc, Graphics, SQLite, Webkit, Media, Surface Manger, OpenGL etc. to
provide a support for android development.
• Following are the summary details of some core android libraries available for android
development.
• Media library for playing and recording an audio and video formats
(iii) SQLite is for database support and FreeType for font support
(iv) Web-Kit for web browser support and SSL for Internet security.
5. Linux Kernel:
Page No: 6 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• Linux Kernel is a bottom layer and heart of the android architecture. It is heart of
Android
architecture that exists at the root of android architecture and contains all the low-level
device
Bluetooth drivers, audio drivers, memory drivers, etc. which are mainly required for the
android device during the runtime.
• The Linux Kernel will provides an abstraction layer between the device hardware and
the remainder of the stack. It is responsible for memory management, power
management, device management, resource access, etc.
Ans Steps to deploy and Android Application on Google Play Store: (List 1 M
and
Step 1: Make a Developer Account Elaboration 3
Step 2: Plan to Sell? Link Your Merchant Account M)
Step 3: Create an App
Step 4: Prepare Store Listing
Page No: 7 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Step 5: Upload APK to an App Release
Step 6: Provide an Appropriate Content Rating
Step 7: Set Up Pricing & Distribution
Step 8: Rollout Release to Publish Your App
MainActivity.java
package in.edu.vpt.insertusingasync;
import android.app.ProgressDialog;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
createData = (Button)findViewById(R.id.button);
createData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sqLiteDatabaseObj = openOrCreateDatabase("AndroidJSonDataBase",
Context.MODE_PRIVATE, null);
} });
}
b) State syntax to create Text View and Image button with any two attributes of each. 4M
ImageButton:
Syntax :
<ImageButton
android:id="@+id/imageButton"
android:layout_width="<width value>"
android:layout_height="<height value>"
app:srcCompat="<image source from drawable folder "/>
Attributes/Properties of ImageButton:
Ans ● A service is an application component which runs without direst interaction with (Explanation
the user in the background. 2 M,
● Services are used for repetitive and potentially long running operations, i.e., Diagram
Internet downloads, checking for new data, data processing, updating content 2M)
providers and the like.
● Service can either be started or bound we just need to call either startService() or
bindService() from any of our android components. Based on how our service
was started it will either be “started” or “bound”
Page No: 12 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Service Lifecycle
1. Started
a. A service is started when an application component, such as an activity,
starts it by calling startService().
b. Now the service can run in the background indefinitely, even if the
component that started it is destroyed.
2. Bound
a. A service is bound when an application component binds to it by calling
bindService().
b. A bound service offers a client-server interface that allows components to
interact with the service, send requests, get results, and even do so across
processes with InterProcess Communication (IPC).
c. Like any other components service also has callback methods. These will
be invoked while the service is running to inform the application of its
state. Implementing these in our custom service would help you in
performing the right operation in the right state. •
d. There is always only a single instance of service running in the app. If you
are calling startService() for a single service multiple times in our
Page No: 13 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
application it just invokes the onStartCommand() on that service. Neither
is the service restarted multiple times nor are its multiple instances created
1. onCreate():
This is the first callback which will be invoked when any component starts the
service. If the same service is called again while it is still running this method
wont be invoked. Ideally one time setup and intializing should be done in this
callback.
2. onStartCommand() /startSetvice()
This callback is invoked when service is started by any component by calling
startService(). It basically indicates that the service has started and can now run
indefinetly.
3. onBind()
To provide binding for a service, you must implement the onBind() callback
method. This method returns an IBinder object that defines the programming
interface that clients can use to interact with the service.
4. onUnbind()
This is invoked when all the clients are disconnected from the service.
5. onRebind()
This is invoked when new clients are connected to the service. It is called after
onRebind
6. onDestroy()
This is a final clean up call from the system. This is invoked just before the
service is being destroyed.
d) State and elaborate the syntax of required class and methods for 4M
Geocoding.
Ans Geocoder: (2 M for
explanation
A class for handling geocoding and reverse geocoding.
and syntax of
Geocoding is the process of transforming a street address or other description of a class, 2 M
location into a (latitude, longitude) coordinate. for
explanation
Reverse geocoding is the process of transforming a (latitude, longitude) coordinate into a and syntax of
(partial) address. The amount of detail in a reverse geocoded location description may any two
vary, for example one might contain the full street address of the closest building, while methods)
another might contain only a city name and postal code.
The Geocoder class requires a backend service that is not included in the core android
framework.
The Geocoder query methods will return an empty list if there no backend service in the
platform. Use the isPresent() method to determine whether a Geocoder implementation
exists.
Page No: 14 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Syntax
Geocoder (Context context)
Syntax
This method returns an array of Addresses that attempt to describe the area immediately
surrounding the given latitude and longitude. The returned addresses should be localized
for the locale provided to this class's constructor.
b. getFromLocationName
Syntax :
Returns an array of Addresses that attempt to describe the named location, which may be
a place name such as "Dalvik, Iceland", an address such as "1600 Amphitheatre Parkway,
Mountain View, CA", an airport code such as "SFO", and so forth. The returned
addresses should be localized for the locale provided to this class's constructor.
c. isPresent
Syntax
Page No: 15 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Returns true if there is a geocoder implementation present that may return results. If true,
there is still no guarantee that any individual geocoding attempt will succeed.
a) Explain with example, code to create GUI using absolute layout (Assume 4M
suitable data).
Ans ● AbsoluteLayout is based on the simple idea of placing each control at an absolute (Explanation
position. We specify the exact x and y coordinates on the screen for each control. 2 M,
This is not recommended for most UI development (in fact AbsoluteLayout is Example 2
currently deprecated) since absolutely positioning every element on the screen makes M)
an inflexible UI that is much more difficult to maintain.
Absolute Layout
● An Absolute Layout lets you specify exact locations (x/y coordinates) of its children.
Absolute layouts are less flexible and harder to maintain than other types of layouts
without absolute positioning. AbsoluteLayout is based on the simple idea of placing
each control at an absolute position.
● We specify for the exact x and y corodinates on the screen for every control. So this
recommended for most UI development (in fact Absolute Layout is currentaly
deprecated)since absolute positioning of every element on the screen makes an
inflexible UI that is much more difficult to maintain.
● Consider what happens if a control needs to be added to the user interface UI, we
would have to change the position of every single element that is shifted by the new
control. This allows child views to be positioned at specified X and Y coordinates
within the containing layout view.
Example
(Note :Any other relevant example using absoluteLayout can be considered, No java
code is expected)
Page No: 16 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
activity_main.xml
<AbsoluteLayoutxmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_x="110px"
android:layout_y="110px"
android:text="User Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_x="250px"
android:layout_y="80px"
android:width="100px"
android:layout_width="200dp"
android:layout_height="wrap_content" />
<TextView
android:layout_x="110px"
android:layout_y="200px"
android:text="Password"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_x="250px"
android:layout_y="150px"
android:width="100px"
android:layout_width="200dp"
android:layout_height="wrap_content" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Log In"
android:layout_x="300px"
android:layout_y="300px"/>
</AbsoluteLayout>
<Button
android:id="@+id/btnDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="96dp"
android:layout_marginBottom="312dp"
android:text="Set Date"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:ignore="DuplicateClickableBoundsCheck" />
<DatePicker
android:id="@+id/dtpcker"
android:layout_width="314dp"
android:layout_height="293dp"
android:layout_marginBottom="368dp"
android:datePickerMode="spinner"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.36"
app:layout_constraintStart_toStartOf="parent" />
<TimePicker
android:id="@+id/timepcker"
android:layout_width="184dp"
android:layout_height="195dp"
android:layout_marginEnd="132dp"
android:layout_marginBottom="108dp"
android:timePickerMode="spinner"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/tvTime"
android:layout_width="130dp"
Page No: 18 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="56dp"
android:layout_marginEnd="232dp"
android:layout_marginBottom="40dp"
android:textSize="20dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<Button
android:id="@+id/btnTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="104dp"
android:layout_marginBottom="48dp"
android:text="Set Time"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
package com.example.datepickereg;
import androidx.appcompat.app.AppCompatActivity;
import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.TimePicker;
import java.util.Calendar;
tvTime.setText(timepcker.getCurrentHour()+":"+timepcker.getCurrentMinute());
}
});
}
}
c) Describe multimedia framework of Android with diagram. 4M
Ans ● The android multimedia system includes multimedia applications, multimedia (Explanation
frameworks, OpenCore engine and hardware abstract for audio/video input/output 2M,
devices. And the goal of the android multimedia framework is to provide a
reliable interface for java services. The multimedia framework consists of several Diagram 2
core dynamic libraries such as libmediajni, libmedia, libmediaplayservice and so M)
on.
● Java classes call the Native C library Libmedia through Java JNI(Java Native
Interface). Libmedia library communications with Media Server guard process
through Android’s Binder IPc (inter process communication) mechanism.
● Media Server process creates the corresponding multimedia service according to
the Java multimedia applications.
● The whole communication between Libmedia and Media Server forms a
Client/Server model
Page No: 20 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
● Typical video/audio data stream works in Android as follows. Particularly, Java
applications first set the URI of the media (from file or network) to PVPlayer
through Java framework, JNI and Native C. In this process, there are no data
stream flows.
● Then PVPlayer processes the media data stream with the steps: demux the media
data to separate video/audio data stream, decode video/audio data, sync
video.audio time, send the decoded data out.
● The below is the description of media codec/format, container and network
protocol supported by the Android platform.
1. Container: The audio file format is a file for storing digital audio data on
a system. This data can be manipulated to reduce the size or change the
quality of the audio. It is a kind of container to store audio information.
2. Audio Format: Any format or codec can be used including the ones
provided by Android or those which are specific devices. However it is
recommended to use the specified file formats as per devices.
3. Network Protocol: Protocols such as RTSP, HTTP,HTTPS are supported
in audio and video playback.
Ans ● Google Play Developer Console is the platform that Google provides for Google (Any 4
Play and Android developers to publish their apps. relevant
● The Google Play Developer console allows app developers and marketers to features 1M
better understand how their apps are performing in terms of growth, technical each )
performance such as crashes or display issues, and financials.
● The console offers acquisition reports and detailed analysis which can help app
devs find out how well an app is really performing.
● The platform is important as it provides developers with access to first party data
(trustworthy information collected about an app’s audience that comes straight
from Google Play) that highlights the real performance of an app.
● It shows the number of impressions an app listing receives and the number of
Installs an app receives from different sources over time.
Page No: 21 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<uses-permission android:name="android.permission.SEND_SMS"/>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="81dp"
android:layout_height="41dp"
android:layout_marginEnd="268dp"
android:layout_marginBottom="576dp"
android:text="To :"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<TextView
android:id="@+id/textView2"
android:layout_width="70dp"
android:layout_height="43dp"
android:layout_marginEnd="276dp"
android:layout_marginBottom="512dp"
android:text="Sms Text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<EditText
android:id="@+id/etPhno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="40dp"
android:layout_marginBottom="572dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<EditText
android:id="@+id/etmsg"
android:layout_width="193dp"
android:layout_height="51dp"
android:layout_marginEnd="56dp"
android:layout_marginBottom="504dp"
Page No: 22 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:ignore="SpeakableTextPresentCheck" />
<Button
android:id="@+id/btnSms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="156dp"
android:layout_marginBottom="400dp"
android:text="SEND SMS"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
package com.example.testreceivesms;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
a) Write a program to convert temperature from celcius to farenhite and vice versa 6M
using Toggle button. (Design UI as per your choice. Write XML and java file)
(Note: Consider the appropriate XML file. All attributes are not required.
In java file all imports are not expected. Different relevant logic/code can be
considered.)
Ans activity_main.xml XML file:
<?xml version="1.0" encoding="utf-8"?> 2M
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
Java Code:
android:layout_width="match_parent"
4M
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/edittext"
android:hint="Enter the temp"/>
<ToggleButton
android:id="@+id/togglebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/edittext"
android:layout_marginTop="35dp"
android:textOff="F to C"
android:textOn="C to F" />
Page No: 24 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/togglebutton"
android:layout_marginTop="56dp" />
</RelativeLayout>
MainActivity.java
package com.example.p1;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.widget.ToggleButton;
Toast.makeText(MainActivity.this,r+"°C",Toast.LENGTH_SHORT).show();
}
Page No: 25 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}
});
}
}
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CAMERA"
android:id="@+id/text"
android:textSize="20dp"
android:gravity="center"/>
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/text"
android:layout_marginTop="81dp"
android:src="@drawable/rose"/>
<Button
android:id="@+id/photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/image"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:text="TAKE PHOTO" />
</RelativeLayout>
Page No: 26 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
MainActivity.java
package com.example.ifcdiv;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
b1=findViewById(R.id.photo);
imageView=findViewById(R.id.image);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent
data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode==CAMERA_REQUEST)
{
Bitmap image= (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(image);
}
}
}
Page No: 27 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
c) Develop and application to send and receive SMS (Design minimal UI as per 6M
your choice. Write XML, java and manifest file)
(Note: Consider appropriate XML file. All attributes are not required. In java
file all imports are not expected. Different relevant login/code can be considered.
Statements showing permissions can be written under AndroidManifest.xml)
Ans Permissions and <receiver> tag required in AndroidManifest.xml XML file:
<uses-permission android:name="android.permission.RECEIVE_SMS" /> 1M
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/> Manifest
<uses-permission android:name="android.permission.WRITE_SMS"/> File:1M
Java Code:
<receiver
4M
android:name=".SmsReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="81dp"
android:layout_height="41dp"
android:layout_marginEnd="268dp"
android:layout_marginBottom="576dp"
android:text="To :"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
<TextView
android:id="@+id/textView2"
android:layout_width="70dp"
android:layout_height="43dp"
android:layout_marginEnd="276dp"
android:layout_marginBottom="512dp"
android:text="Sms Text"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
Page No: 28 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<EditText
android:id="@+id/etPhno"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="40dp"
android:layout_marginBottom="572dp"
android:ems="10"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<EditText
android:id="@+id/etmsg"
android:layout_width="193dp"
android:layout_height="51dp"
android:layout_marginEnd="56dp"
android:layout_marginBottom="504dp"
android:inputType="textPersonName"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
tools:ignore="SpeakableTextPresentCheck" />
<Button
android:id="@+id/btnSms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="156dp"
android:layout_marginBottom="400dp"
android:text="SEND SMS"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
MainActivity.java
package com.example.testreceivesms;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
Page No: 29 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
public class MainActivity extends AppCompatActivity {
SmsReceiver sms= new SmsReceiver();
EditText et1,et2;
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1=findViewById(R.id.etPhno);
et2=findViewById(R.id.etmsg);
b1=findViewById(R.id.btnSms);
if(ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.SEN
D_SMS)!=
PackageManager.PERMISSION_GRANTED)
{
ActivityCompat.requestPermissions(MainActivity.this,new
String[]{Manifest.permission.SEND_SMS},100);
}
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
String phno= et1.getText().toString();
String msg=et2.getText().toString();
SmsManager smsManager= SmsManager.getDefault();
smsManager.sendTextMessage(phno,null,msg,null,null);
Toast.makeText(MainActivity.this,"Sms sent successfully",
Toast.LENGTH_LONG).show();
}
catch(Exception e)
{
Toast.makeText(MainActivity.this,"Sms failed to send... try again",
Toast.LENGTH_LONG).show();
}
}
});
}
@Override
protected void onStart() {
super.onStart();
IntentFilter filter=new
IntentFilter("android.provider.Telephony.SMS_RECEIVED");
registerReceiver(sms,filter);
}
@Override
protected void onStop() {
super.onStop();
unregisterReceiver(sms);
Page No: 30 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}
}
SmsReceiver.java
package com.example.testreceivesms;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.widget.Toast;
if (bundle != null) {
// Retrieve the SMS Messages received
Object[] sms = (Object[]) bundle.get("pdus");
a) Write a program to implement Android Activity Life Cycle. Use toast messages 6M
to display message through life cycle.
(Note: No XML code is required. In java file all imports are not expected.)
Ans package com.example.p1; Use of any 6
import androidx.appcompat.app.AppCompatActivity; methods of
import android.os.Bundle; Activity life
import android.widget.Toast; cycle : 1 M
public class MainActivity extends AppCompatActivity { each
@Override
Page No: 31 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(getApplicationContext(),"Activity
created",Toast.LENGTH_LONG).show();
}
@Override
protected void onStart() {
super.onStart();
Toast.makeText(getApplicationContext(),"Activity
Started",Toast.LENGTH_LONG).show();
}
@Override
protected void onStop() {
super.onStop();
Toast.makeText(getApplicationContext(),"Activity
Stop",Toast.LENGTH_LONG).show();
}
@Override
protected void onDestroy() {
super.onDestroy();
Toast.makeText(getApplicationContext(),"Activity
Destroy",Toast.LENGTH_LONG).show();
}
@Override
protected void onPause() {
super.onPause();
Toast.makeText(getApplicationContext(),"Activity
Pause",Toast.LENGTH_LONG).show();
}
@Override
protected void onRestart() {
super.onResume();
Toast.makeText(getApplicationContext(),"Activity
Restart",Toast.LENGTH_LONG).show();
@Override
protected void onResume() {
super.onResume();
Toast.makeText(getApplicationContext(),"Activity
Resume",Toast.LENGTH_LONG).show();
}
}
b) Develop an application to display Google map with user's current location. 6M
(Note : Consider the appropriate XML file. All attributes are not required.
Page No: 32 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
In java file all imports are not expected. Different relevant logic/code can be
considered.)
Ans act ivity_main.xml XML file:
<?xml version="1.0" encoding="utf-8"?> 1M
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" Java Code:
android:layout_width="match_parent" 5M
android:layout_height="match_parent"
tools:context=".MainActivity">
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/google_map"
android:name="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>
MainActivity.Java
package com.example.location;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.fragment.app.FragmentActivity;
import android.Manifest;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import android.widget.Toast;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
fusedLocationProviderClient =
LocationServices.getFusedLocationProviderClient(this);
fetchLastLocation();
}
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,new
String[]{Manifest.permission.ACCESS_FINE_LOCATION},REQUEST_CODE);
return;
}
Task<Location> task = fusedLocationProviderClient.getLastLocation();
task.addOnSuccessListener(new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
if(location!=null)
{
currentlocation=location;
Toast.makeText(getApplicationContext(),currentlocation.getLatitude()+""+current
location.getLongitude(), Toast.LENGTH_SHORT).show();
SupportMapFragment supportMapFragment =
(SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.go
ogle_map);
supportMapFragment.getMapAsync(MainActivity.this);
}
}
});
}
Page No: 34 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
@Override
public void onMapReady(@NonNull GoogleMap googleMap) {
LatLng latLng=new
LatLng(currentlocation.getLatitude(),currentlocation.getLongitude());
MarkerOptions markerOptions=new MarkerOptions().position(latLng)
.title("I am Here");
googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng,5));
googleMap.addMarker(markerOptions);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[]
permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case REQUEST_CODE:
if (grantResults.length > 0 && grantResults[0] ==
PackageManager.PERMISSION_GRANTED) {
fetchLastLocation();
}
break;
}
}
}
c) Design UI using table layout to display buttons with 0 9 numbers on it. Even display 6M
submit and clear button. When user clicks on particular buttons and later when
clicks on submit button, it should display the numbers clicked.
(Note: Consider the appropriate XML file. All attributes are not required.
In java file all imports are not expected. Different relevant logic/code can be
considered.)
Ans activity_main.xml XML file:
<?xml version="1.0" encoding="utf-8"?> 3M
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
Java Code:
android:layout_width="match_parent"
3M
android:layout_height="match_parent"
android:stretchColumns="*"
tools:context=".MainActivity">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
Page No: 35 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/button0"
android:text="0"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/button1"
android:text="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button2"
android:text="2" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/button3"
android:text="3"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/button4"
android:text="4"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:id="@+id/button5"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="6"
android:id="@+id/button6"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="7"
Page No: 36 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:id="@+id/button7"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
android:id="@+id/button8"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="9"
android:id="@+id/button9"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Submit"
android:id="@+id/submit"/>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="Clear"
android:id="@+id/clear"/>
</TableRow>
</TableLayout>
(Java File)
package com.example.p1;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
a=button0.getText().toString();
}
});
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a=button1.getText().toString();
}
});
button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a=button2.getText().toString();
}
});
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a=button3.getText().toString();
}
});
button4.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a=button4.getText().toString();
}
});
button5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a=button5.getText().toString();
Page No: 38 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
}
});
button6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a=button6.getText().toString();
}
});
button7.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a=button7.getText().toString();
}
});
button8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a=button8.getText().toString();
}
});
button9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
a=button9.getText().toString();
}
});
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(),a,Toast.LENGTH_LONG).show(); }
});
}
}
Page No: 39 | 39
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER – 2022 EXAMINATION
Subject Name Mobile Application Development Model Answer Subject Code: 22617
Important Instructions to examiners: XXXXX
1) The answers should be examined by key words and not as word-to-word as given in the model answer
scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not
applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The
figures drawn by candidate and model answer may vary. The examiner may give credit for any equivalent
figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may
vary and there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based
on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual
(English + Marathi) medium is introduced at first year of AICTE diploma Programme from academic year
2021-2022. Hence if the students in first year (first and second semesters) write answers in Marathi or
bilingual language (English +Marathi), the Examiner shall consider the same and assess the answer based
on matching of concepts with model answer.
Q. Sub Note: As Android programs contain many of the auto generated code statements from IDE, Marking
No. Q. while assessing such answers correct logical steps taken to obtain the required output can be Scheme
N. considered.
Answer
Ans The OHA is the group that is in charge of the Android smartphones operating system. It was (Define : 1
created by Google. The Open Handset Alliance (OHA) is consortium of multiple companies M, Stating
like Samsung, Sony, Intel and many more to provide services and deploy handsets using goal 1 M)
android platform.
The Open Handset Alliance (OHA) is an association whose goal is to develop open standards
for mobile devices, promote innovation in mobile phones and provide a better experience for
consumers at a lower cost.
Ans An Android Virtual Device (AVD) is a configuration that defines the characteristics of an (Define : 2
Android phone, tablet, Wear OS, Android TV, or Automotive OS device that you want to M ,any valid
simulate in the Android Emulator. The AVD Manager is an interface you can launch from definition
Android Studio that helps you create and manage AVDs. should be
considered)
Page No: 1 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
c) State how the APK files are built? 2M
Ans The javac compiler compiles the java source file into the class file. (For each
The dx tool takes all the class files of your application and generates a single .dex file which step 1/2 M)
is a platform specific tool.
Then Android Assets Packaging Tool (aapt) handles the packaging process and finally
creates an executable file with extension .apk.
An APK file contains all of a program's code (such as .dex files), resources, assets,
certificates, and manifest file.
OR
Components of UI
Menu Bar
Toolbar
Navigation Bar
Editor Tabs
Editor
Project Explorer
Status Bar
Tool Buttons
e) State the uses of Intent in Android. 2M
Ans An Intent is a messaging object you can use to request an action from another app component. (1 M for
Intents are used for facilitating communication between components like Activities, Services each use, 2
and Broadcast Receivers. uses
expected)
Ans Content Providers are used to share data between two applications. This can be implemented (1 M for
in two ways: each
1. When you want to implement the existing content provider in another application. significance
2. When you want to create a new content provider that can share its data with other ,
Applications
Ans User Interface: The user interface of the Android operating system is straight forward, and (1 M for
these features make it very user friendly. each
feature, 4
Multiple Language Support: Android supports multiple languages in its operating system and features
one can change the language very easily based on one’s requirement, the International expected)
languages supported are English, Germany, Chinese, Dutch, French, German, Japanese,
Korean, Russian, and many more also some native language of India is also Supported Like
Hindi, Marathi, Gujarati, Punjabi and many more.
Multi-tasking: Android provides support to run apps and services in the background with ease
which allows the users to use multiple apps at the same time.
Connectivity: Android has extensive support to the connectivity and it supports connectivity
such as WiFi, Bluetooth, Hotspot, CDMA, GSM, NFC, VOLTE, UBB, VPN, 3G network
band, and 4G Network Band.
Extensive Application Support: Android have Play store which is used as the major tool to
download and update applications on the operating system, however, one can download the
installer(often called as APK file) and install it manually, but it is not much recommended as
third party applications could be prone to some security breach in the smartphones.
Ans Android SDK is a collection of libraries and Software Development tools that are essential for (1 M for
Developing Android Applications. Whenever Google releases a new version or update of each
Page No: 3 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Android Software, a corresponding SDK also releases with it. In the updated or new version of feature, any
SDK, some more features are included which are not present in the previous version. Android 4 features
SDK consists of some tools which are very essential for the development of Android expected)
Application. These tools provide a smooth flow of the development process from developing
and debugging. Android SDK is compatible with all operating systems such as Windows,
Linux, macOS, etc.
1. Android Tool: This tool helps in managing the Android Virtual Device projects as well as
the installed components of the software development kit.
2. Emulator Tool: It helps us in testing the applications without the need of using the
application on an actual device.
3. Dalvik Debug Monitor Server(DDMS): DDMS is very useful for debugging the Android
Application.
4. Android Debug Bridge (ADB): It is a very versatile command-line tool and is helpful for
the communication between the developer and the Emulator or the Android device that is
connected.
Ans The Android security model is primarily based on a sandbox and permission mechanism. Each 2 M for
application is running in a specific Dalvik virtual machine with a unique user ID assigned to it, explanation
which means the application code runs in isolation from the code of all other applications. , 2 M for
Therefore, one application has not granted access to other applications’ files. explaining
permissions
Android application has been signed with a certificate with a private key Know the owner of , any 2
the application is unique. This allows the author of the application will be identified if needed. permissions
When an application is installed in the phone is assigned a user ID, thus avoiding it from expected)
affecting it other applications by creating a sandbox for it. This user ID is permanent on which
devices and applications with the same user ID are allowed to run in a single process. This is a
way to ensure that a malicious application has Cannot access / compromise the data of the
genuine application. It is mandatory for an application to list all the resources it will Access
during installation. Terms are required of an application, in the installation process should be
user-based or interactive Check with the signature of the application.
Declaring and Using Permissions
The purpose of a permission is to protect the privacy of an Android user. Android apps must
request permission to access sensitive user data (such as contacts and SMS), as well as certain
system features (such as camera and internet). Depending on the feature, the system might grant
the permission automatically or might prompt the user to approve the request.
Permissions are divided into several protection levels. The protection level affects whether
runtime permission requests are required. There are three protection levels that affect third-
party apps: normal, signature, and dangerous permissions.
Normal permissions: Normal permissions cover areas where your app needs to access data or
resources outside the app’s sandbox, but where there’s very little risk to the user’s privacy or
Page No: 4 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
the operation of other apps. For example, permission to set the time zone is a normal
permission. If an app declares in its manifest that it needs a normal permission, the system
automatically grants the app that permission at install time. The system doesn’t prompt the user
to grant normal permissions, and users cannot revoke these permissions.
Signature permissions: The system grants these app permissions at install time, but only when
the app that attempts to use permission is signed by the same certificate as the app that defines
the permission.
Dangerous permissions: Dangerous permissions cover areas where the app wants data or
resources that involve the user’s private information, or could potentially affect the user’s
stored data or the operation of other apps. For example, the ability to read the user’s contacts is
a dangerous permission. If an app declares that it needs a dangerous permission, the user must
explicitly grant the permission to the app. Until the user approves the permission, your app
cannot provide functionality that depends on that permission. To use a dangerous permission,
your app must prompt the user to grant permission at runtime. For more details about how the
user is prompted, see Request prompt for dangerous permission.
d) Elaborate the need of permissions in Android. Explain the permissions to set 4M
system functionalitics like SEND-SMS, bluetooth.
Ans The purpose of a permission is to protect the privacy of an Android user. Android apps must(2 M for
request permission to access sensitive user data (such as contacts and SMS), as well as certain
explanation
system features (such as camera and internet). Depending on the feature, the system might grant
of need, 1
the permission automatically or might prompt the user to approve the request. M each for
explaining
android. permission. SEND_SMS permissions
Allows the app to send SMS messages. This may result in unexpected charges. of Sms and
Malicious apps may cost you money by sending messages without your confirmation. bluetooth)
Page No: 6 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
getMinute(): getCurrentMinute() method was deprecated in API level 23. From api level 23
we have to use getMinute(). This method returns an integer value.
TimePicker simpleTimePicker = (TimePicker)findViewById(R.id.simpleTimePicker);
int minutes = simpleTimePicker.getCurrentMinute();
int minutes = simpleTimePicker.getMinute();
5. setIs24HourView(Boolean is24HourView): This method is used to set the mode of the
Time picker either 24 hour mode or AM/PM mode. In this method we set a Boolean value
either true or false. True value indicate 24 hour mode and false value indicate AM/PM mode.
TimePicker simpleTimePicker = (TimePicker)findViewById(R.id.simpleTimePicker);
simpleTimePicker.setIs24HourView(true);
6. is24HourView(): This method is used to check the current mode of the time picker. This
method returns true if its 24 hour mode or false if AM/PM mode is set.
TimePicker simpleTimePicker = (TimePicker)findViewById(R.id.simpleTimePicker);
Boolean mode=simpleTimePicker.is24HourView();
7.setOnTimeChangedListener(TimePicker.OnTimeChangedListener
onTimeChanged(): This method is used to set the callback that indicates the time has been
adjusted by the user.
onTimeChanged(TimePicker view, int hourOfDay, int minute) is an override function of this
listener in which we have three parameters first is for TimePicker, second for getting hour of
the day and last is for getting the minutes after changing the time of the time picker.
TimePicker simpleTimePicker = (TimePicker)findViewById(R.id.simpleTimePicker);
simpleTimePicker.setOnTimeChangedListener(new TimePicker.OnTimeChangedListener() {
@Override
public void onTimeChanged(TimePicker view, int hourOfDay, int minute) {
}
});
b) Explain the steps to install and configure Android studio and SDK. 4M
Ans Download the latest version of Android Studio from above URL and launch Android 4 M for
Studio.exe file by double clicking on it. steps
The initial android studio setup screen will open in that click Next to continue for further
steps of environment setup
Now we need to select a required components to setup an android environment. Here
we selected all three components (Android Studio, Android SDK and Android Virtual
Device) and click Next.
Now we need to agree the License agreements to proceed further, click on I Agree
button
Now we need to specify the local machine drive location to install Android Studio and
Android SDK.
After selecting the location path to install required components, click Next.
Now select the start menu folder to create a shortcut for android studio and click Install
Once we click Install button the installation process will start and click Next after
completion of Installation.
After that it will show installation completion wizard in that click Finish to launch
android studio While launching Android Studio it will give you an option to import
Page No: 7 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
settings from previous version of studio. In case if you don’t have any previous version,
select second option and click OK
Now android studio will open a welcome wizard window in that click Next to validate
our current Android SDK and development environment setup
Now select a Standard installation type and click Next to install a common settings and
options
Now verify settings and click Finish to complete android studio setup process
After completion of required components installation click on Finish
After completion of all required components installation, we will be able to see Android
Studio welcome window
c) Explain the activity life cycle. 4M
Ans Diagram 2
M
explanation
2M
Page No: 8 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
onCreate (): Called then the activity is created. Used to initialize the activity, for
example create the user interface.
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.
Page No: 10 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<ProgressBar
android:id="@+id/progressBar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:indeterminate="false"
android:max="100"
android:minHeight="50dp"
android:minWidth="200dp"
android:progress="1" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/progressBar"
android:layout_below="@+id/progressBar"/>
</RelativeLayout>
Java file:
package in.edu.vpt.progressbar;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.widget.ProgressBar;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private ProgressBar progressBar;
private int progressStatus = 0;
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
textView = (TextView) findViewById(R.id.textView);
// Start long running operation in a background thread
new Thread(new Runnable() {
public void run() {
Page No: 12 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
while (progressStatus < 100) {
progressStatus += 1;
new Handler(Looper.getMainLooper()).post(new Runnable() {
public void run() {
progressBar.setProgress(progressStatus);
textView.setText(progressStatus+"/"+progressBar.getMax());
}
});
try {
// Sleep for 200 milliseconds.
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
}
}
c) Explain Android system architecture in detail. 4M
Ans Diagram
2 M,
Explanation
2M
1. Applications:
• The top layer of android architecture is Applications. The native and third party applications
like Contacts, Email, Music, Gallery, Clock, Games, etc. whatever we will build those will be
installed on this layer only.
Page No: 13 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• The application layer runs within the Android run time using the classes and services made
available from the application framework.
2. Application Framework:
• The Application Framework provides the classes used to create an Android application. It also
provides a generic abstraction for hardware access and manages the user interface and
application resources.
• It basically provides the services through which we can create the particular class and make
that class helpful for the Applications creation.
• The application framework includes services like telephony service, location services,
notification manager, NFC service, view system, etc. which we can use for application
development as per our requirements.
3. Android Runtime:
• Android Runtime environment is an important part of Android rather than an internal part and
it contains a components like core libraries and the Dalvik virtual machine.
• The Android run time is the engine that powers our applications along with the libraries and
it forms the basis for the application framework.
(i) Dalvik Virtual Machine (DVM) is a register-based virtual machine like Java Virtual
Machine (JVM).
It is specially designed and optimized for android to ensure that a device can run multiple
instances efficiently. It relies on the Linux kernel for threading and low-level memory
management.
(ii) The core libraries in android runtime will enable us to implement an android applications
using standard JAVA programming language.
4. Platform Libraries:
• The Platform Libraries includes various C/C++ core libraries and Java based libraries such as
SSL, libc, Graphics, SQLite, Webkit, Media, Surface Manger, OpenGL etc. to provide a
support for android development.
5. Linux Kernel:
• Linux Kernel is a bottom layer and heart of the android architecture. It is heart of Android
architecture that exists at the root of android architecture and contains all the low-level device
drivers for the various hardware components of an Android device.
• Linux Kernel is responsible for device drivers, power management, memory management,
device management and resource access. It manage all the drivers such as display drivers,
camera drivers, Bluetooth drivers, audio drivers, memory drivers, etc. which are mainly
required for the android device during the runtime.
• The Linux Kernel will provide an abstraction layer between the device hardware and the
remainder of the stack. It is responsible for memory management, power management, device
management, resource access, etc.
d) Explain the procedure of Geo-coding and reverse Geo-coding. 4M
Page No: 14 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• The following code shows how we can find out the address of a location we have just touched and
using the getFromLocation() method: reverse
classMapOverlay extends com.google.android.maps.Overlay geocoding 2
M
{
@Override
publicboolean draw(Canvas canvas, MapViewmapView,
boolean shadow, long when)
{
//...
}
@Override
publicbooleanonTouchEvent(MotionEvent event, MapViewmapView)
{
//---when user lifts his finger---
if (event.getAction() == 1) {
GeoPoint p = mapView.getProjection().fromPixels(
(int) event.getX(),
(int) event.getY());
Geocoder geoCoder = new Geocoder(
getBaseContext(), Locale.getDefault());
try {
List<Address> addresses = geoCoder.getFromLocation(
p.getLatitudeE6() / 1E6,
p.getLongitudeE6() / 1E6, 1);
String add = "";
if (addresses.size() > 0)
{
for (inti=0; i<addresses.get(0).getMaxAddressLineIndex();
i++)
add += addresses.get(0).getAddressLine(i) + "n";
}
Toast.makeText(getBaseContext(), add, Toast.LENGTH_SHORT).show();
}
catch (IOException e) {
e.printStackTrace();
}
return true;
}
else
return false;
}
}
Page No: 15 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Reverse-geocoding:
If we know the address of a location but want to know its latitude and longitude, we can do so
via reverse-Geocoding. Again, we can use the Geocoder class for this purpose.
• The following code shows how we can find the exact location of the Empire State Building
by using the getFromLocationName() method:
Geocoder geoCoder = new Geocoder(this, Locale.getDefault());
try {
List<Address> addresses = geoCoder.getFromLocationName(
"empire state building", 5);
String add = "";
if (addresses.size() > 0) {
p = new GeoPoint(
(int) (addresses.get(0).getLatitude() * 1E6),
(int) (addresses.get(0).getLongitude() * 1E6));
mc.animateTo(p);
mapView.invalidate();
}
} catch (IOException e) {
e.printStackTrace();
}
Once. the location is found, the above code navigates the map to the location.
e) Develop an application to send and receive SMS (Write only Java and 4M
permission tag in manifest file).
Ans Permissions and <receiver> tag required in AndroidManifest.xml Manifest
<uses-permission android:name="android.permission.RECEIVE_SMS" /> File:1M
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/> Java Code:
<uses-permission android:name="android.permission.WRITE_SMS"/> 3M
<receiver
android:name=".SmsReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
MainActivity.java
(Cosidering appropriate layout file with 2 edit text boxes namely for phone number,
message and a button for sending sms)
package com.example.testreceivesms;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
Page No: 16 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import androidx.core.content.ContextCompat;
import android.Manifest;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
@Override
protected void onStop() {
super.onStop();
unregisterReceiver(sms);
}
}
SmsReceiver.java
package com.example.testreceivesms;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.widget.Toast;
if (bundle != null) {
// Retrieve the SMS Messages received
Object[] sms = (Object[]) bundle.get("pdus");
Page No: 18 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
a) Develop a program to send and receive an Email. 6M
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText1"
android:layout_alignLeft="@+id/editText1"
android:layout_marginTop="20dp" />
<EditText
android:id="@+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText2"
android:layout_alignLeft="@+id/editText2"
android:layout_marginTop="30dp" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText1"
android:layout_alignBottom="@+id/editText1"
android:layout_alignParentLeft="true"
android:text="Send To:"
android:textColor="#0F9D58" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
Page No: 19 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText2"
android:layout_alignBottom="@+id/editText2"
android:layout_alignParentLeft="true"
android:text="Email Subject:"
android:textColor="#0F9D58" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText3"
android:layout_alignBottom="@+id/editText3"
android:text="Email Body:"
android:textColor="#0F9D58" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText3"
android:layout_alignLeft="@+id/editText3"
android:layout_marginLeft="76dp"
android:layout_marginTop="20dp"
android:text="Send email!!" />
</RelativeLayout>
MainActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
// define objects for edit text and button
Button button;
EditText sendto, subject, body;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Page No: 20 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
// attach setOnClickListener to button with Intent object define in it
button.setOnClickListener(view -> {
String emailsend = sendto.getText().toString();
String emailsubject = subject.getText().toString();
String emailbody = body.getText().toString();
@Override
protected void onResume() {
super.onResume();
Page No: 21 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
registerReceiver(gml, intf);
}
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(gml);
}
}
Gmailrerciever..java
package com.example.myemailprog;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.BitmapFactory;
import android.widget.Toast;
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myemailprog">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyEmailProg">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Page No: 22 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
</intent-filter>
</activity>
<receiver android:name="GmailReceiver"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.PROVIDER_CHANGED"
android:priority="-10">
</action>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="content" android:host="gmail-ls"
android:pathPattern="/unread/.*">
</data>
</intent-filter>
</receiver>
</application>
</manifest>
b) Develop a program for providing bluetooth connectivity. 6M
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="49dp"
android:text="TURN_ON" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button1"
android:layout_below="@+id/button1"
android:layout_marginTop="27dp"
android:text="DISCOVERABLE" />
Page No: 23 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/button2"
android:layout_below="@+id/button2"
android:layout_marginTop="28dp"
android:text="TURN_OFF" />
</RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:androclass="http://schemas.android.com/apk/res/android"
package="com.example.bluetooth"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.bluetooth.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
MainActivity.java
package com.example.bluetooth;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
Page No: 24 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
}
}
});
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Page No: 25 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
mBluetoothAdapter.disable();
//out.append("TURN_OFF BLUETOOTH");
Toast.makeText(getApplicationContext(), "TURNING_OFF BLUETOOTH", Toast.LENGT
H_LONG);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
c) Develop a program to implement 6M
<GridView
android:id="@+id/gridview1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:columnWidth="50dp"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth" >
</GridView>
<ImageView
android:id="@+id/full_logo"
android:layout_width="match_parent"
Page No: 26 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"
app:srcCompat="@drawable/android_logo" />
</LinearLayout>
Placed image that has to be displayed in drawable folder
package in.msbte.controls_exam_ques;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import android.widget.ListView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//List View
adapter = new ArrayAdapter<String>(this, R.layout.simple_item, sampleArray);
ListView listView = (ListView) findViewById(R.id.sample_list);
listView.setAdapter(adapter);
//Grid View
gridView = (GridView) findViewById(R.id.gridview1);
adapter1 = new ArrayAdapter<String>(this, R.layout.simple_item, alphabets);
gridView.setAdapter(adapter1);
}
}
6. Attempt any TWO of the following: 12 M
Page No: 27 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
a) Develop an application to store customer's details like, customer-id, customer-name, 6M
mobile number, address, pin-code and retrieve customer information using customer-id
in SQLite databases.
(Any other relevant logic can be considered)
Ans activity_main.xml Layout File
<?xml version="1.0" encoding="utf-8"?> : 1M
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" Java File :
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" Correct
android:layout_height="match_parent" Logics for
tools:context=".MainActivity">
Create
table : 1M
<TextView Insertion of
android:text="Insert Customer Details" record : 2M
android:layout_width="wrap_content" Retrival of
android:layout_height="wrap_content" data : 2M
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:id="@+id/textView"
android:gravity="center"
android:textSize="20dp"
android:textColor="#000000"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="ID"
android:id="@+id/editid"
android:layout_below="@+id/textView"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Name"
android:id="@+id/editname"
android:layout_below="@+id/editid"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Mobile No."
android:id="@+id/editmobile"
android:layout_below="@+id/editname"/>
Page No: 28 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Address"
android:lines="3"
android:id="@+id/editaddress"
android:layout_below="@+id/editmobile"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Pin Code"
android:id="@+id/editpincode"
android:layout_below="@+id/editaddress"/>
<Button
android:text="Insert Data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/editpincode"
android:layout_centerHorizontal="true"
android:id="@+id/button" />
<TextView
android:text="Search Customer Details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_centerHorizontal="true"
android:id="@+id/textView1"
android:gravity="center"
android:textSize="20dp"
android:layout_below="@+id/button"
android:textColor="#000000"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Enter ID"
android:id="@+id/editsearchid"
android:layout_below="@+id/textView1"/>
Page No: 29 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<Button
android:text="Search Data"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/editsearchid"
android:layout_centerHorizontal="true"
android:id="@+id/button1" />
</RelativeLayout>
MainActivity.java
package in.msbte.database;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EnterData = (Button)findViewById(R.id.button);
SearchData = (Button)findViewById(R.id.button1);
editTextID = (EditText)findViewById(R.id.editid);
editTextName = (EditText)findViewById(R.id.editname);
editMobileNo = (EditText)findViewById(R.id.editmobile);
editAddress = (EditText)findViewById(R.id.editaddress);
editPincode = (EditText)findViewById(R.id.editpincode);
editSearchid = (EditText)findViewById(R.id.editsearchid);
EnterData.setOnClickListener(new View.OnClickListener() {
@Override
Page No: 30 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
public void onClick(View view) {
sqLiteDatabaseObj = openOrCreateDatabase("AndroidJSonDataBase",
Context.MODE_PRIVATE, null);
sqLiteDatabaseObj.execSQL("CREATE TABLE IF NOT EXISTS
AndroidJSonTable(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, cid
VARCHAR, name VARCHAR, mobile VARCHAR, address VARCHAR, pincode
VARCHAR);");
cid = editTextID.getText().toString();
cname = editTextName.getText().toString() ;
cmobile = editMobileNo.getText().toString();
caddress = editAddress.getText().toString();
cpincode = editPincode.getText().toString();
sql_query = "INSERT INTO AndroidJSonTable (cid, name, mobile, address,
pincode) VALUES('"+cid+"', '"+cname+"', '"+cmobile+"', '"+caddress+"', '"+cpincode+"');";
sqLiteDatabaseObj.execSQL(sql_query);
Toast.makeText(getApplicationContext(), "Data Inserted Successfully",
Toast.LENGTH_LONG).show();
}
});
SearchData.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sid = editSearchid.getText().toString();
Cursor cursor = sqLiteDatabaseObj.rawQuery( "select * from AndroidJSonTable
where cid="+sid+"", null );
StringBuffer buffer= new StringBuffer();
while (cursor.moveToNext())
{
String cid =cursor.getString(1);
String name =cursor.getString(2);
String mob =cursor.getString(3);
String addr =cursor.getString(4);
String pcode =cursor.getString(5);
buffer.append(cid+ " " + name + " " + mob +" " + addr +" " + pcode +"
\n");
Toast.makeText(getApplicationContext(), buffer,
Toast.LENGTH_LONG).show();
} }); } }
b) Write a program to find the direction from user's current location to MSBTE, 6M
Bandra. (Write only Java and manitest file).
(Note : Any other relevant logic to get the required output can also be considered.)
Page No: 31 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans AndroidManifest.xml Manifest
file :2M
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" Java File :
package="com.example.msbte.google_map_currentlocationroute"> 4M
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
MainActivity.java
import android.Manifest;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.net.Uri;
import android.provider.Settings;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
Page No: 32 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import com.karumi.dexter.Dexter;
import com.karumi.dexter.MultiplePermissionsReport;
import com.karumi.dexter.PermissionToken;
import com.karumi.dexter.listener.DexterError;
import com.karumi.dexter.listener.PermissionRequest;
import com.karumi.dexter.listener.PermissionRequestErrorListener;
import com.karumi.dexter.listener.multi.MultiplePermissionsListener;
import java.util.List;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.clear();
Log.d("mylog", "Added Markers");
mMap.addMarker(place1);
mMap.addMarker(place2);
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(googlePlex), 5000,
null);
}
@Override
public void onTaskDone(Object... values) {
if (currentPolyline != null)
currentPolyline.remove();
currentPolyline = mMap.addPolyline((PolylineOptions) values[0]);
}
@Override
public void onPermissionRationaleShouldBeShown(List<PermissionRequest>
permissions, PermissionToken token) {
token.continuePermissionRequest();
}
}).
withErrorListener(new PermissionRequestErrorListener() {
@Override
public void onError(DexterError error) {
Toast.makeText(getApplicationContext(), "Some Error! ",
Toast.LENGTH_SHORT).show();
}
})
Page No: 35 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
.onSameThread()
.check();
}
startLocationUpdates();
mLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
if(mLocation == null){
startLocationUpdates();
}
if (mLocation != null) {
// mLatitudeTextView.setText(String.valueOf(mLocation.getLatitude()));
//mLongitudeTextView.setText(String.valueOf(mLocation.getLongitude()));
Page No: 36 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
} else {
Toast.makeText(this, "Location not Detected", Toast.LENGTH_SHORT).show();
} }
@Override
public void onConnectionSuspended(int i) {
Log.i(TAG, "Connection Suspended");
mGoogleApiClient.connect();
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.i(TAG, "Connection failed. Error: " + connectionResult.getErrorCode());
}
@Override
protected void onStart() {
super.onStart();
if (mGoogleApiClient != null) {
mGoogleApiClient.connect();
} }
@Override
protected void onStop() {
super.onStop();
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
} }
@Override
public void onLocationChanged(Location location) {
tvLocation.setText(String.valueOf(location.getLatitude() +"
"+String.valueOf(location.getLongitude())));
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
if(isFirstTime){
//code to draw path on map
getDirection = findViewById(R.id.btnGetDirection);
getDirection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new FetchURL(MainActivity.this).execute(getUrl(place1.getPosition(),
place2.getPosition(), "driving"), "driving");
}
});
Page No: 38 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<EditText
android:id="@+id/num1"
android:layout_below="@+id/heading"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Number 1"
android:inputType="number" />
<EditText
android:id="@+id/num2"
android:layout_below="@+id/num1"
android:hint="Enter Number 2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number" />
<TextView
android:id="@+id/result"
android:layout_below="@+id/num2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:text="Result" />
<Button
android:id="@+id/sum"
android:layout_below="@id/result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="+" />
<Button
android:id="@+id/sub"
android:layout_below="@id/result"
android:layout_toRightOf="@id/sum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="-" />
<Button
Page No: 39 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:id="@+id/div"
android:layout_below="@id/result"
android:layout_toRightOf="@id/sub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="/" />
<Button
android:id="@+id/mul"
android:layout_below="@id/result"
android:layout_toRightOf="@id/div"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="x"/>
</RelativeLayout>
MainActivity.java
package in.msbte.calculator;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
public EditText e1, e2;
Button add, sub , mul, div;
TextView t1;
int num1, num2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
e1 = (EditText) findViewById(R.id.num1);
e2 = (EditText) findViewById(R.id.num2);
t1 = (TextView) findViewById(R.id.result);
add = (Button) findViewById(R.id.sum);
mul = (Button) findViewById(R.id.mul);
div = (Button) findViewById(R.id.div);
sub = (Button) findViewById(R.id.sub);
add.setOnClickListener(new View.OnClickListener() {
Page No: 40 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
@Override
public void onClick(View view) {
num1 = Integer.parseInt(e1.getText().toString());
num2 = Integer.parseInt(e2.getText().toString());
int sum = num1 + num2;
t1.setText(Integer.toString(sum));
}
});
sub.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
num1 = Integer.parseInt(e1.getText().toString());
num2 = Integer.parseInt(e2.getText().toString());
int sum = num1 - num2;
t1.setText(Integer.toString(sum));
}
});
mul.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
num1 = Integer.parseInt(e1.getText().toString());
num2 = Integer.parseInt(e2.getText().toString());
int sum = num1 * num2;
t1.setText(Integer.toString(sum));
}
});
div.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
num1 = Integer.parseInt(e1.getText().toString());
num2 = Integer.parseInt(e2.getText().toString());
int sum = num1 / num2;
t1.setText(Integer.toString(sum));
}
});
}
}
Page No: 41 | 41
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
SUMMER – 2023 EXAMINATION
Model Answer – Only for the Use of RAC Assessors
Page No: 1 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• In the Android ecosystem this translates to inter-dependence between users,
developers, and equipment makers. One cannot exist without the other:
▪ Google develops android
▪ Users buy devices and applications
▪ Original Equipment makers sell devices, sometimes bundled with applications
▪ Developers buy devices, then make and sell applications
▪ Freelance Android Developer developers have the skills to contribute to the
ecosystem for android development , they are who creates their own applications and
published them on googles play store.
Ans Android Fragment is the part of activity, it is also known as sub-activity. There can be more Explanation
2M
than one fragment in an activity.
Page No: 2 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
We can create Fragments by extending Fragment class or by inserting a Fragment into our
Activity layout by declaring the Fragment in the activity’s layout file, as
a <fragment> element.
Fragments were added in Honeycomb version of Android i.e API version 11. We can add,
replace or remove Fragment’s in an Activity while the activity is running.
Fragment can be used in multiple activities.
We can also combine multiple Fragments in a single activity to build a multi-plane UI.
We can only show a single Activity on the screen at one given point of time so we were not
able to divide the screen and control different parts separately. With the help of Fragment’s
we can divide the screens in different parts and controls different parts separately
• In Android, you can use SmsManager API or devices Built-in SMS application to 4 points
send SMS's
2M
• Android SMS is stored in PDU (protocol description unit) format
• SmsManager class takes care of sending the SMS message.
• We just need to get an instance of it and send the SMS message.
• We need to add permission to SEND_SMS in the Android manifest file.
Ans The android platform supports three broad categories of sensors. 2 M for List
• Motion Sensors
These are used to measure acceleration forces and rotational forces along with three
axes.
• Environmental sensors
These are used to measure the environmental changes such as temperature, humidity etc.
• Position sensors
Page No: 3 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
2. Attempt any THREE of the following: 12 M
• The Open Handset Alliance (OHA) is a business alliance that was created for the
purpose of developing open mobile device standards.
• The OHA has approximately 80 member companies, including HTC, Dell, Intel,
Motorola, Qualcomm and Google.
Importance of OHA
• Lower overall handset costs: Opens up resources, which facilitates the focus on
creating innovative applications, solutions and services.
• Developer-friendly environment: In the open-source community, developers share
notes to expedite application development.
• Post-development: Provides an ideal channel for application marketing and
distribution.
Ans The Dalvik Virtual Machine (DVM) is an android virtual machine optimized for mobile Explain 2
devices. M
Dalvik VM is also a virtual machine that is highly optimized for mobile devices. Importance
2M
Thus, it provides all the three things, that are memory management, high performance as
well as battery life.
Page No: 4 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
The Dex compiler converts the class files into the .dex file that run on the Dalvik VM.
Multiple class files are converted into one dex file.
The javac tool compiles the java source file into the class file.
The dx tool takes all the class files of your application and generates a single .dex file. It is a
platform-specific tool.
The Android Assets Packaging Tool (aapt) handles the packaging process.
c) Describe the process of getting the map API key. 4M
Click on the API key option to generate your API key. After clicking on this option your
API key will be generated
d) Explain multimedia framework in android. 4M
Page No: 5 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Multimedia Framework Proper
Explanation
4 marks
Page No: 6 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Go to Android https://developer.android.com/studio to get the Android Studio executable or steps 4
zip file. marks
Step 2:
● Click on the Download Android Studio Button.
● Click on the “I have read and agree with the above terms and conditions” checkbox
followed by the download button
● Click on the Save file button in the appeared prompt box and the file will start
downloading.
Step 3:
After the downloading has finished, open the file from downloads and will prompt the
following dialog box. Click on next. In the next prompt, it’ll ask for a path for installation.
Choose a path and hit next.
Step 4:
It will start the installation, and once it is completed, it will be like the image shown below.
Step 5:
Once “Finish” is clicked, it will ask whether the previous settings need to be imported [if the
android studio had been installed earlier], or not. It is better to choose the ‘Don’t import
Settings option’. Click the OK button.
Step 6:
This will start the Android Studio. Meanwhile, it will be finding the available SDK
components.
Step 7:
After it has found the SDK components, it will redirect to the Welcome dialog box. Choose
Standard and click on Next. Now choose the theme, whether the Light theme or the Dark
one. The light one is called the IntelliJ theme whereas the dark theme is called Dracula.
Choose as required. Click on the Next button.
Step 8:
Now it is time to download the SDK components. Click on Finish. Components begin to
download let it complete. The Android Studio has been successfully configured. Now it’s
time to launch and build apps. Click on the Finish button to launch it.
Step 9:
Click on Start a new Android Studio project to build a new app.
Page No: 7 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans GridView : (1 M for
explanation
Android GridView shows items in two-dimensional scrolling grid (rows & columns) and the of
grid items are not necessarily predetermined but they automatically inserted to the layout GridView,1
using a ListAdapter. M for
explaining
GridView Attributes
attributes, 2
Following are the important attributes specific to GridView – M example)
[any two
attributes
Sr.No Attribute & Description should be
considered
1 android:id
for 1 M,
This is the ID which uniquely identifies the layout. any valid
example of
2 android:columnWidth GridView
for 2 M]
This specifies the fixed width for each column. This could be in px, dp,
sp, in, or mm.
3 android:gravity
Specifies the gravity within each cell. Possible values are top, bottom,
left, right, center, center_vertical, center_horizontal etc.
4 android:horizontalSpacing
Defines the default horizontal spacing between columns. This could be
in px, dp, sp, in, or mm.
5 android:numColumns
Defines how many columns to show. May be an integer value, such as
"100" or auto_fit which means display as many columns as possible to
fill the available space.
6 android:stretchMode
Defines how columns should stretch to fill the available empty space, if
any. This must be either of the values −
• none − Stretching is disabled.
• spacingWidth − The spacing between each column is stretched.
• columnWidth − Each column is stretched equally.
• spacingWidthUniform − The spacing between each column is
uniformly stretched..
Page No: 8 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
7 android:verticalSpacing
Defines the default vertical spacing between rows. This could be in px,
dp, sp, in, or mm.
activity_main.xml Code :
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:columnWidth="90dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp"
tools:context=".MainActivity">
</GridView>
activity_listview.xml code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/btn"
android:layout_width="fill_parent"
Page No: 9 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"
android:layout_gravity="center" />
</LinearLayout>
MainActivity.java
package com.example.myapplication.gridviewbuttons;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.GridView;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
GridView gridview;
String arr[] = new String[15];
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gridview = findViewById(R.id.gridview);
for (int i = 0; i < 15; i++) {
arr[i] = Integer.toString(i + 1);
}
ArrayAdapter<String> ad = new ArrayAdapter<String>(this, R.layout.activity_listview,
R.id.btn, arr);
gridview.setAdapter(ad);
}
}
Ans Text to Speech converts the text written on the screen to speech like you have written “Hello Proper
World” on the screen and when you press the button it will speak “Hello World”. Text-to- explanation
speech is commonly used as an accessibility feature to help people who have trouble reading
Page No: 10 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
on-screen text, but it’s also convenient for those who want to be read too. This feature has 4 marks
come out to be a very common and useful feature for the users.
In android, by using TextToSpeech class we can easily convert our text into voice and it
supports different types of speaking languages. We can choose the speaking language based
on our requirements in the android application.
The android TextToSpeech instance can only be used to synthesize text once it has
completed its initialization so implement TextToSpeech.
OnInitListener to notify the completion of initialization. During the initialization, we can set
the audio pitch rate, audio speed, type of language to speak, etc. based on our requirements.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="30dp"
tools:context=".MainActivity">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/Text"
android:layout_marginBottom="20dp"
android:hint="Enter your text"
android:gravity="center"
android:textSize="16dp"/>
Page No: 11 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<Button
android:layout_width="wrap_content"
android:id="@+id/btnText"
android:layout_height="wrap_content"
android:text="Click"
android:layout_gravity="center"/>
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="70dp"
android:gravity="center_horizontal"
android:text="MobileApplicationDevelopment"
android:textSize="36sp" />
</LinearLayout>
MainActivity.java
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import java.util.Locale;
Page No: 12 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
public class MainActivity extends AppCompatActivity {
EditText Text;
Button btnText;
TextToSpeech textToSpeech;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Text = findViewById(R.id.Text);
btnText = findViewById(R.id.btnText);
btnText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
textToSpeech.speak(Text.getText().toString(),TextToSpeech.QUEUE_FLUSH,null);
}
Page No: 13 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
});
}
}
Ans The android project contains different types of app modules, source code files, and resource 1 M for
files. listing of
directory
1. Manifests Folder structure , 3
2. Java Folder M for
explanation
3. res (Resources) Folder )
Page No: 15 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• Drawable Folder
• Layout Folder
• Mipmap Folder
• Values Folder
4. Gradle Scripts
Manifests Folder
Manifests folder contains AndroidManifest.xml for creating our android application. This
file contains information about our application such as the Android version, metadata, states
package for Kotlin file, and other application components. It acts as an intermediator
between android OS and our application.
Java folder
The Java folder contains all the java source code (.java) files that we create during the app
development, including other Test files. If we create any new project using Java, by default
the class file MainActivity.java will be created.
Resource (res) folder
The resource folder is the most important folder because it contains all the non-code sources
like images, XML layouts, and UI strings for our android application.
res/drawable folder
It contains the different types of images used for the development of the application. We
Page No: 16 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
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.
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.
Page No: 17 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SELECT TIME"
android:id="@+id/btn_time"
android:layout_below="@+id/in_time"/>
</RelativeLayout>
MainActivity.java
package com.example.myapplication.timepickerwithspinnermode;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TimePicker;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Calendar;
public class MainActivity extends AppCompatActivity implements
View.OnClickListener {
Button btnTimePicker;
EditText txtTime;
private int mHour, mMinute;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnTimePicker=(Button)findViewById(R.id.btn_time);
Page No: 18 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
txtTime=(EditText)findViewById(R.id.in_time);
btnTimePicker.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (v == btnTimePicker) {
// Get Current Time
final Calendar c = Calendar.getInstance();
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
// Launch Time Picker Dialog
TimePickerDialog timePickerDialog = new TimePickerDialog(this,
new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay,
int minute) {
txtTime.setText(hourOfDay + ":" + minute);
}
}, mHour, mMinute, false);
timePickerDialog.show();
}
}
}
c) Explain property animation method to animate the properties of view object with example. 4M
Ans A property animation changes a property's (a field in an object) value over a specified length (2 M for
of time. To animate something, you specify the object property that you want to animate, explaining
such as an object's position on the screen, how long you want to animate it for, and what property
values you want to animate between. animation
method, 2
The property animation system lets you define the following characteristics of an animation: M for
example )
Duration: You can specify the duration of an animation. The default length is 300 ms.
Time interpolation: You can specify how the values for the property are calculated as a
Page No: 19 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
function of the animation's current elapsed time.
Repeat count and behavior: You can specify whether or not to have an animation repeat
when it reaches the end of a duration and how many times to repeat the animation. You can
also specify whether you want the animation to play back in reverse. Setting it to reverse
plays the animation forwards then backwards repeatedly, until the number of repeats is
reached.
Animator sets: You can group animations into logical sets that play together or sequentially
or after specified delays.
Frame refresh delay: You can specify how often to refresh frames of your animation. The
default is set to refresh every 10 ms, but the speed in which your application can refresh
frames is ultimately dependent on how busy the system is overall and how fast the system
can service the underlying timer.
Strings.xml
<resources>
<string name="app_name">Animation</string>
<string name="blink">BLINK</string>
<string name="fade">FADE</string>
<string name="move">MOVE</string>
</resources>
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
Page No: 20 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:id="@+id/imageview"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:contentDescription="@string/app_name"
android:src="@drawable/image" />
<LinearLayout
android:id="@+id/linear1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/imageview"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:weightSum="3">
<Button
android:id="@+id/BTNblink"
style="@style/TextAppearance.AppCompat.Widget.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:padding="3dp"
android:text="@string/blink"
android:textColor="@color/white" />
Page No: 21 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<Button
android:id="@+id/BTNfade"
style="@style/TextAppearance.AppCompat.Widget.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:padding="3dp"
android:text="@string/fade"
android:textColor="@color/white" />
<Button
android:id="@+id/BTNmove"
style="@style/TextAppearance.AppCompat.Widget.Button"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:padding="3dp"
android:text="@string/move"
android:textColor="@color/white" />
</LinearLayout>
</RelativeLayout>
1) Blink Animation
Page No: 22 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="500"
android:repeatMode="reverse"
android:repeatCount="infinite"/>
</set>
2) Fade Animation
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<alpha
android:duration="1000"
android:fromAlpha="0"
android:toAlpha="1" />
<alpha
android:duration="1000"
android:fromAlpha="1"
android:startOffset="2000"
android:toAlpha="0" />
</set>
3) Move Animation
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
Page No: 23 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
<translate
android:fromXDelta="0%p"
android:toXDelta="75%p"
android:duration="700" />
</set>
MainActivity.java
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
ImageView imageView;
Button blinkBTN, fadeBTN, moveBTN;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imageView = findViewById(R.id.imageview);
blinkBTN = findViewById(R.id.BTNblink);
fadeBTN = findViewById(R.id.BTNfade);
moveBTN = findViewById(R.id.BTNmove);
Page No: 24 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
blinkBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add blink animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink_animation);
imageView.startAnimation(animation);
}
});
fadeBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add fade animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_animation);
imageView.startAnimation(animation);
}
});
moveBTN.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// To add move animation
Animation animation =
AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move_animation);
imageView.startAnimation(animation);
}
});
}
}
Page No: 25 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
d) Describe permissions required for android application development. 4M
Ans The Android security model is primarily based on a sandbox and permission mechanism. (2 Marks
Each application is running in a specific Dalvik virtual machine with a unique user ID for two
assigned to it, which means the application code runs in isolation from the code of all other permission
applications. Therefore, one application has not granted access to other applications’ files. explanation
)
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 affects whether
runtime permission requests are required. There are three protection levels that affect third-
party apps: normal, signature, and dangerous permissions.
Normal permissions cover areas where your app needs to access data or resources outside
the app’s sandbox, but where there’s very little risk to the user’s privacy or the operation of
other apps. For example, permission to set the time zone is a normal permission. If an app
declares in its manifest that it needs a normal permission, the system automatically grants
the app that permission at install time. The system doesn’t prompt the user to grant normal
permissions, and users cannot revoke these permissions.
Signature permissions: The system grants these app permissions at install time, but only
when the app that attempts to use permission is signed by the same certificate as the app that
defines the permission.
Dangerous permissions: Dangerous permissions cover areas where the app wants data or
resources that involve the user’s private information, or could potentially affect the user’s
stored data or the operation of other apps. For example, the ability to read the user’s contacts
is a dangerous permission. If an app declares that it needs a dangerous permission, the user
must explicitly grant the permission to the app. Until the user approves the permission, your
app cannot provide functionality that depends on that permission. To use a dangerous
permission, your app must prompt the user to grant permission at runtime. For more details
about how the user is prompted, see Request prompt for dangerous permission.
Page No: 26 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
MapsActivity.java
import android.os.Build;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.location.LocationServices;
import android.location.Location;
import android.Manifest;
Page No: 27 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.content.pm.PackageManager;
import android.support.v4.content.ContextCompat;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
@Override
Page No: 28 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
}
protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API).build();
mGoogleApiClient.connect();
}
@Override
public void onConnected(Bundle bundle) {
Page No: 29 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
mLocationRequest.setInterval(1000);
mLocationRequest.setFastestInterval(1000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY)
;
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,
mLocationRequest, this);
}
@Override
public void onConnectionSuspended(int i) {
@Override
public void onLocationChanged(Location location) {
mLastLocation = location;
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
//Place current location marker
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Position");
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
Page No: 30 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
mCurrLocationMarker = mMap.addMarker(markerOptions);
Note: only the permission line can be written , no entire code is required for manifest file.
<TextView
android:text="Employee Registration Form"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:id="@+id/textView"
android:gravity="center"
android:textSize="20dp"
android:textColor="#000000"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="ID"
android:id="@+id/editid"
android:layout_below="@+id/textView"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Name"
android:id="@+id/editname"
android:layout_below="@+id/editid"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Mobile No."
android:id="@+id/editmobile"
android:layout_below="@+id/editname"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Address"
android:lines="3"
android:id="@+id/editaddress"
android:layout_below="@+id/editmobile"/>
<EditText
android:layout_width="fill_parent"
Page No: 32 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"
android:hint="Pin Code"
android:id="@+id/editpincode"
android:layout_below="@+id/editaddress"/>
<Button
android:text="Submit Details"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/editpincode"
android:layout_centerHorizontal="true"
android:id="@+id/button" />
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Student Feedback Form" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name"
android:id="@+id/editname"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Roll No."
Page No: 33 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:id="@+id/editrollno"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Class"
android:id="@+id/editclass"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter your Feedback"
android:lines="3"
android:id="@+id/editfeedback"/>
<Button
android:text="Submit Feedback"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:id="@+id/button" />
</LinearLayout>
MapsActivity.java
package com.example.feedback;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
submitBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
sqLiteDatabaseObj = openOrCreateDatabase("FeedbaseDataBase",
Context.MODE_PRIVATE, null);
sqLiteDatabaseObj.execSQL("CREATE TABLE IF NOT EXISTS
Student(id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name
VARCHAR, rollno VARCHAR, class VARCHAR, feedback VARCHAR);");
sname = std_name.getText().toString();
srollno = std_rollno.getText().toString() ;
sclass = std_class.getText().toString();
sfeedback = std_class.getText().toString();
sql_query = "INSERT INTO Student (name, rollno, class, feedback)
VALUES('"+sname+"', '"+srollno+"', '"+sclass+"', '"+sfeedback+"')";
sqLiteDatabaseObj.execSQL(sql_query);
Toast.makeText(getApplicationContext(), "Feedback Submitted
Successfully", Toast.LENGTH_LONG).show();
}
});
}
}
Ans Geocoding is the process of transforming a street address or other description of a (Geocoding ,
location into a (latitude, longitude) coordinate. Reverse
Geocoding
Reverse geocoding is the process of transforming a (latitude, longitude) coordinate into a Explanation :
(partial) address. 3 M,
Example :
The amount of detail in a reverse geocoded location description may vary, for example 3M)
one might contain the full street address of the closest building, while another might
contain only a city name and postal code.
Page No: 35 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
The Geocoder class is used for handling geocoding and reverse geocoding.
activity_maps.xml
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="example.com.mapexample.MapsActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:layout_width="248dp"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:hint="Search Location" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android: > android:text="Search" />
</LinearLayout>
</fragment>
AndroidManifest.xml
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
MapsActivity.java
package example.com.mapexample;
import android.location.Address;
import android.location.Geocoder;
import android.os.Build;
import android.support.v4.app.FragmentActivity;
Page No: 36 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.os.Bundle;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.location.LocationServices;
import android.location.Location;
import android.Manifest;
import android.content.pm.PackageManager;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import java.io.IOException;
import java.util.List;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be
used.
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
Page No: 37 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
}
protected synchronized void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API).build();
mGoogleApiClient.connect();
}
@Override
public void onConnected(Bundle bundle) {
mLocationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION)
== PackageManager.PERMISSION_GRANTED) {
LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,
mLocationRequest, this);
}
@Override
public void onConnectionSuspended(int i) {
Page No: 38 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
@Override
public void onLocationChanged(Location location) {
mLastLocation = location;
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
//Place current location marker
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Position");
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));
mCurrLocationMarker = mMap.addMarker(markerOptions);
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
} catch (IOException e) {
e.printStackTrace();
}
Page No: 39 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Address address = addressList.get(0);
LatLng latLng = new LatLng(address.getLatitude(), address.getLongitude());
mMap.addMarker(new MarkerOptions().position(latLng).title(location));
mMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
Toast.makeText(getApplicationContext(),address.getLatitude()+"
"+address.getLongitude(),Toast.LENGTH_LONG).show();
}
}
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Paired devices:"
android:id="@+id/textView1"
android:textColor="#ff34ff06"
android:textSize="25dp"
android:layout_below="@+id/button1" />
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/listView"
Page No: 40 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_alignParentBottom="true"
android:layout_below="@+id/textView1" />
</RelativeLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:androclass="http://schemas.android.com/apk/res/android"
package="com.example.bluetooth"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-
permission android:name="android.permission.BLUETOOTH_ADMIN" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=" in.org.msbte.bluetooth.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
MainActivity.java
package in.org.msbte.bluetooth;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
Page No: 41 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.widget.ListView;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.Set;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1 = (Button) findViewById(R.id.button1);
BA = BluetoothAdapter.getDefaultAdapter();
lv = (ListView)findViewById(R.id.listView);
}
lv.setAdapter(adapter);
}
}
<TextView
android:id="@+id/secTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message"
android:layout_marginLeft="100dp" />
<EditText
android:id="@+id/msgTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:ems="10" />
<Button
android:id="@+id/btnSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:text="Send SMS" />
</LinearLayout>
MainActivity.java
package in.org.msbte.sendsmsexample;
import android.content.Intent;
import android.net.Uri;
import android.provider.Telephony;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
Page No: 43 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
public class MainActivity extends AppCompatActivity {
smgr.sendTextMessage(txtMobile.getText().toString(),null,txtMessage.getText().toString(),null,null);
Toast.makeText(MainActivity.this, "SMS Sent Successfully",
Toast.LENGTH_SHORT).show();
}
catch (Exception e){
Toast.makeText(MainActivity.this, "SMS Failed to Send, Please try again",
Toast.LENGTH_SHORT).show();
}
}
});
}
}
c) Explain how linear and frame layout is used to design an android application with 6M
suitable example.
Ans LinearLayout (2 M : For
each layout
• Android LinearLayout is a view group that aligns all children in either vertically explanation,
or horizontally. 1 M for
each layout
• Linear layout in Android allow us to arrange components horizontally in a single
example)
column or
vertically in a single row.
• Vertically or horizontally direction depends on attribute android: orientation.
• Linear layout is simple and easy to use, it creates a scroll bar if the length of the
window exceeds the length of the screen.
• Linear Layout are one of the simplest and common type of layouts used by
Android developers to keep controls within their interfaces. The linear layout
works as much as its name implies, it organizes the controls either a vertical or
horizontal pattern.
• When the layout’s orientation is set to vertical, all child controls within
Page No: 44 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
organized in a single column, and when the layout’s orientation is set to
horizontal, all child controls within in single row.
Example
Frame Layout
• Frame Layout is designed to block out an area on the screen to display a single item.
Generally, FrameLayout should be used to hold a single child view, because it can be
difficult to organize child views in a way that's scalable to different screen sizes without
the children overlapping each other.
Page No: 45 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• Frame layouts are one of the simplest layout types used to organize controls within the
user interface of an Android application. The purpose of FrameLayout is to allocate an
area of screen.
• Frame layouts are one of the most efficient types of layouts used by Android developers
to organize view controls. They are used less often than some other layouts, simply
because they are generally used to display only one view, or views which overlap.
• The frame layout is often used as a container layout, as it generally only has a single
child view (often another layout, used to organize more than one view).
Example
Page No: 46 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Page No: 47 | 47
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER – 2023 EXAMINATION
Model Answer – Only for the Use of RAC Assessors
Page No: 1 | 48
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
Reverse Geocoding :
Reverse geocoding is the process of transforming a (latitude, longitude) coordinate
into a (partial) address.
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
Page No: 2 | 48
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:
Attribute Description
Page No: 3 | 48
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
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
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.
Within Android Studio, you can install the Android SDK as follows:
c) Explain the need of Android Operating System. Also describe any four 4M
features of android.
Open Source:
Multi-Platform Support
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.
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
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
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
7) Storage and Battery Swap
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.
@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
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
mMap = googleMap;
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
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
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.
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.
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
Page No: 10 | 48
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.
Page No: 11 | 48
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
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
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
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;
}
}
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
There is a constant pool for every It has a constant pool for every class.
application.
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
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.
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.
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
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
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
import android.widget.RadioButton;
import android.widget.Toast;
RadioButton male,female;
Button b1;
@Override
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
Page No: 18 | 48
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)
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
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
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
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();
}
}
}
}
Page No: 22 | 48
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
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
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
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: > android:text="+" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
Page No: 25 | 48
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_margin="1dp"
android: > android:text="-" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="1dp"
android: > android:text="*" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="1dp"
android: > android:text="/" />
</GridLayout>
</RelativeLayout>
Page No: 26 | 48
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
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:
<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
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
.
Page No: 30 | 48
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));
}
}
android:paddingTop="@dimen/activity_vertical_margin"
Page No: 31 | 48
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: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
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
android:layout_height="wrap_content"
android:id="@+id/button"
android:layout_below="@+id/editText"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:textSize="15dp" />
</RelativeLayout>
<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
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;
TextToSpeech t1;
EditText ed1;
Button b1;
@Override
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);
@Override
Page No: 34 | 48
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
Toast.makeText(getApplicationContext(),
toSpeak,Toast.LENGTH_SHORT).show();
});
if(t1 !=null){
t1.stop();
t1.shutdown();
super.onPause();
Page No: 35 | 48
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" />
Page No: 36 | 48
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";
Page No: 37 | 48
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";
Page No: 38 | 48
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();
Page No: 39 | 48
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
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);
Page No: 41 | 48
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);
Page No: 42 | 48
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
empSalaryEdt.setText(empSalary);
// displaying a toast message that our employee database has been updated.
Toast.makeText(UpdateempActivity.this, "Employee Record Updated..",
Toast.LENGTH_SHORT).show();
Page No: 43 | 48
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.
1)Preparing your app for release is a multistep process involving the following tasks:
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
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
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.
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.
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
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;
Page No: 46 | 48
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);
}
Page No: 47 | 48
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