Sample Question Paper
Scheme-I
Mobile Application Development
Q 1) Attempt any FIVE of the Following
a) List features of Anroid Operating System.
[Link]. Feature & Description
1
Beautiful UI
Android OS basic screen provides a beautiful and intuitive user interface.
2
Connectivity
GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi, LTE, NFC and
WiMAX.
3
Storage
SQLite, a lightweight relational database, is used for data storage purposes.
4
Media support
H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC, AAC 5.1, MP3, MIDI,
Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP.
5
Messaging
SMS and MMS
6
Web browser
Based on the open-source WebKit layout engine, coupled with Chrome's V8 JavaScript
engine supporting HTML5 and CSS3.
7
Multi-touch
Android has native support for multi-touch which was initially made available in
handsets such as the HTC Hero.
8
Multi-tasking
User can jump from one task to another and same time various application can run
simultaneously.
9
Resizable widgets
Widgets are resizable, so users can expand them to show more content or shrink them to
save space.
10
Multi-Language
Supports single direction and bi-directional text.
11
GCM
Google Cloud Messaging (GCM) is a service that lets developers send short message data
to their users on Android devices, without needing a proprietary sync solution.
12
Wi-Fi Direct
A technology that lets apps discover and pair directly, over a high-bandwidth peer-to-peer
connection.
13
Android Beam
A popular NFC-based technology that lets users instantly share, just by touching two
NFC-enabled phones together.
b) Define Android Virtual Devices (AVD)
Ans: 1. It is configuration that defines characteristics of an android phone, tv,
tablet, os or automotive os device that you want to simulate in android emulator.
2. Use AVD manager to create an AVD.
3. AVD is used for creating android application.
Hardware profile/sketch
System Image
Android virtual device Skin
Android Emulated storage area
c) Write the directory path where images are stored while developing
android application
Ans: Images are stored in drawable and mipmap folder
We stored our image in the resource file by following steps.
1. First we need to download the image from our browser.
2. Then we have to copy it from the folder in which the image is stored.
3. Then after that we have to simple paste it in the resource
If we want to put the icon or launcher icon then we have to paste the image in the mipmap
folder and select the shape and size
Example
Manifest [Link]
Java [Link]
[Link]
res mipmap [Link]
layout
drawable [Link]
value -[Link]
-[Link]
-[Link]
d) List all attributes to develop a simple button.
Ans:
[Link] Attribute & Description
android:background
1
This is a drawable to use as the background.
android:contentDescription
2
This defines text that briefly describes content of the view.
android:id
3
This supplies an identifier name for this view.
android:visibility
4
This controls the initial visibility of the view.
android:gravity:
The gravity attribute is an optional attribute which is used to control the alignment of
5
the text like left, right, center, top, bottom, center_vertical, center_horizontal etc.
e) Write the syntax for Intent-Filter tag
Ans: Syntax:
<intent-filter android:icon=”drawable resource”
android:Label=”string resource”
android:priority=”interger”>
<action android:name=”[Link]”/>
<category android:name=”[Link]”/>
</intent-filter>
f) Define services in android operating system
Android service is a component that is used to perform operations on the background
such as playing music, handle network transactions, interacting content providers etc. It
doesn’t has any UI (user interface).
The service runs in the background indefinitely even if application is destroyed.
Moreover, service can be bounded by a component to perform interactivity and inter
process communication (IPC).
There can be two forms of a service. The lifecycle of service can follow two different
paths: started or bound.
Types of services: a) Foreground service
b) Background service
c) Bound service
g) Enlist the steps to publish the android application
ans: 1. Create a Google Developer Account
2. Links to our Merchant Account
3. Creating an App
4. Preparing Store Listing
5. Graphic Assets
6. Languages & Translations
7. Categorization
8. Contact Details
9. Privacy Policy
10. Upload APK to release your app
11. Provide the right content rating
12. Setup pricing & distribution
13. Publishing your app
Q.2) Attempt any THREE of the following.
a) Describe the Android architecture in detail.
Ans. Mostly Android has following layers :-
1] Applications
2] Application Framework
3] Libraries
4] Android Runtime
5] Linux Kernel
1] Applications
i. All applications in application layer are written using Java language.
ii. The various core application that an android device provides
- Email client - Calculator
- SMS/MMS - Clock
- Maps - Albums
- Camera - Voice Dial
- Calendar - Media Player
- Maps - Brower’s
- Contacts - Alarm
2] Application Framework
This layer is second layer, contains 10 components.
i. Activity Manager :
This layer manages lifecycle of applications & provides navigations to it.
ii. Window Manager :
It manages the window surface, screen layout & performs window related jobs.
iii. View Manager :
It manages view of the manager.
iv. Content Manager :
Enables applications to access data from other applications or to share their own
data
v. Notification Manager :
This manager will provide the notification that will manage the notification of
system.
vi. Package Manager :
It manages the packages. Sometimes, we can download application package
which is required.
vii. Telephony Manager :
It manages the receiver calls or any voice calls.
viii. Resource Manager:
It manages resources such as layout files, string files & graphics files.
ix. Location Manager :
It helps to locate mobile devices.
x. XMPP Service Manager (Extensible Messaging & Presence Protocol) :
Every mobile phone has service like music app, SMS app, Brower, Ringtone,
etc.
3] Libraries
i. This is third layer of android architecture is written in C & C++ libraries.
ii. This layer is communicated through application framework layer. This
communication happens through Java Native Interface(JVI)package.
iii. It includes 9 major components.
1) Surface Manager :-
We have seen application framework for following manager :- Activity
Manager, Window Manager, View System Manager.
• It gives a frame, button, text field
• Setting size frame, button, image
• We have to interact with this manager called surface renered by each
component of frame.
2) Open GL/ES (Graphics Libraries / Embedded System) :
It provides 3D graphics libraries which have to be implemented by Java
Application.
3) Media Framework :
It is used for picture quality & audio/video playing.
4) SQLite :
Used to connect with database other RDBMS are heavy weight that out
application (open-source).
5) Freetype :
Responsible for to support font quality images (bitmap, images)
6) Webkit :
Responsible for giving browser support Google Chrome, Apple Safari.
7) SGL(Scalable graphics libraries) :
Responsible for implementing low level graphics by JNI.
8) SSL(Secured Socket layer) :
Used in internal application when we want to access through mobile we need
SSL supports for HTTP/TCP Protocol.
9) Libc :
When we want to access code C libraries headers then this components are
useful.
4] Android Runtime:
1) Core libraries: Following libraries provide most of functionalities defined
in java libraries.
- Data Structure
- File Access
- Utilities
- Graphics
2) DVM (Dalvik Virtual Machine): i. it is like JVM in android to run apps,
optimized low processing power & low memory required.
ii. .dex files are built from .class file at time of complication & provide high
efficiency.
iv. It allows Memory Management
- Security - thread supports
5] Linux Kernel:
i. Basic layer is Linux Kernel, entire OS is scale on top of Linux 2.6 Kernel
with architecture change made by google.
ii. This layer has 10 components which are nothing but [Link] run
time gives .dex file which converted from .class file .dex file goes to Linux
Kernel & call suitable driver so it can communicate with corresponding drivers.
a. Display driver b. Bluetooth driver
c. Binder Driver d. Wi-Fi Driver
e. Auto Driver f. Camera Driver
g. Flash driver h. Keypad driver
i. USB driver j. Power Management
b) Differentiate between JVM & DVM.
Ans:
Ans:
JVM DVM
1. JVM Support Multiple O.S. [Link] only Android O.S.
1. Compiles Java Byte Code. 2. Compile Dalvik Byte code.
3. Forms separate classes in separate 3. Forms multiple class in one .dex
.class byte code file. byte code file.
4. Stack based Virtual Machine 4. Register based Virtual Machine
Architecture. Architecture.
5. It runs on more memory. 5. It runs on less memory.
6. Java Source Code 6. Java Source Code
Java Byte Code Java Byte Code
Java Byte Code by JVM Dalvik Byte Code
Dalvik Executable by DVM
c) Explain the activity lifecycle.
Ans.
An Android activity is one screen of the android app’s user interface. In that
way an android activity is very similar to window in a desktop application.
Method Description Syntax
onCreate called when activity is public void onCreate(Bundle
first SavedinstanceState) {
created. [Link](savedinstanceState);
}
onStart called when activity is public void onStart()
becoming visible to the user. {
[Link]();
}
onResume called when activity will start interacting public void onStart()
with the user. {
[Link]();
}
onPause called when activity is not public void onPause()
visible to the user. {
[Link]();
}
onStop called when activity is no public void onStop()
longer visible to the user. {
[Link]();
}
onRestart called after your activity is public void
stopped, prior to start. onRestart()
{
[Link]();
}
onDestroy called before the activity is public void
destroyed. onDestroy()
{
[Link]();
}
Ex. Program to show Activity Life Cycle
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
Log.d("lifecycle","onCreate invoked");
}
@Override
protected void onStart() {
[Link]();
Log.d("lifecycle","onStart invoked"); }
@Override
protected void onResume() {
[Link]();
Log.d("lifecycle","onResume invoked"); }
@Override
protected void onPause() {
[Link]();
Log.d("lifecycle","onPause invoked"); }
@Override
protected void onStop() {
[Link]();
Log.d("lifecycle","onStop invoked"); }
@Override
protected void onRestart() {
[Link]();
Log.d("lifecycle","onRestart invoked"); }
@Override
protected void onDestroy() {
[Link]();
Log.d("lifecycle","onDestroy invoked"); }
}
d) Discuss the need of permission in android. Describe the permission to set
system functionalities like Bluetooth, camera.
Ans:
1. Permission requests protect sensitive information available from a device and should
only be used when access to information is necessary for the functioning of your app.
2. 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).
3. For example, suppose your app needs to be able to take pictures with the device
camera. Your app can request the CAMERA permission, which allows your app to
access the camera directly.
4. Permissions to set system Bluetooth
<uses-feature android:name="[Link]" />
<uses-permission android:name="[Link]" />
<uses-permission android:name="[Link].BLUETOOTH_ADMIN" />
<uses-permission
android:name="[Link].ACCESS_COARSE_LOCATION" />
<uses-permission android:name="[Link].ACCESS_FINE_LOCATION"
/>
5.
permissions to set system camera
Camera Features - Your application must also declare use of camera features, for example:
<uses-feature android:name="[Link]" />
<uses-permission android:name="[Link]" />
Q 3 attempt any three of the following
a) Explore the steps to install and configure android studio and sdk.
Ans:
Step 1: Right click on downloaded .exe file and run as administrator
Step2 : you will see setup wizard device click on next>
Step3: Select android virtual device and click on next>
Step 4: it will show the installation path default it could be in c:\Program
files\Android\, if you want to change the installation directory, you can
freely use the browse button and give the location and click on next>
Step 5: Click on install
Step 6: actual installation in progress
After completing installation process click on next>
Click on start android studio and click on finish
This is how we can install android studio on windows 10, as we click on start
android studio option the android studio will launch automatically as soon as
we click on finish button.
Now lets move on to android studio setup
Step 7: Here is welcome screen click on nest >
Step 8: it will ask for the android studio installation type mostly we can go
with standard setup if you have any specific configuration setup then you can
select the custom option to manual setup.
Now I am choosing standard setup
click on next>
step 9: it will ask for the UI theme by default it would be intel then directly
you can click on next.
Step 10: it will ask for the confirmation for installation setting wizard
Step 11: it will download all necessary components to launch the android
studio and setting up the environment after download and installation click
on finish.
b) Explain Date and Time picker with its methods
Ans: 1. Date Picker:
I. Android Date Picker allows you to select the date consisting of day,
month and year in your custom user interface. For this functionality
android provides DatePicker and DatePickerDialog components.
II. In order to use TimePicker class, you have to first define the
TimePicker component in your [Link]. It is define as below –
<DatePicker
android:id="@+id/dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:datePickerMode="calendar"/>
III. Methods:
getDayOfMonth():-This method gets the selected day of month.
getMonth():-This method gets the selected month
getYear():-This method gets the selected year
setSpinnersShown(boolean shown):- This method sets whether the spinners
are shown
getCalendarView():- This method returns calendar view
getFirstDayOfWeek():-This Method returns first day of the week
2) TimePicker:
I. Android Time Picker allows you to select the time of day in either 24
hour or AM/PM mode. The time consists of hours, minutes and clock
format. Android provides this functionality through TimePicker class.
II. In order to use TimePicker class, you have to first define the TimePicker
component in your [Link]. It is define as below −
<TimePicker
android:id="@+id/timePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
III. Methods:
is24HourView():-This method returns true if this is in 24 hour
view else false
isEnabled():- This method returns the enabled status for this view
setCurrentHour(Integer currentHour):- This method sets the
current hour
setCurrentMinute(Integer currentMinute):- This method sets the
current minute
setEnabled(boolean enabled):- This method set the enabled state of
this view
setIs24HourView(Boolean is24HourView):- This method set
whether in 24 hour or AM/PM mode
c) Describe the significance of SQLite database in Android.
Ans:
1. SQLite is an open-source relational database i.e. used to perform database operations
on android devices such as storing, manipulating or retrieving persistent data from the
database.
2. It is embedded in android by default. So, there is no need to perform any database
setup or administration task.
3. SQLiteDatabase has methods to create, delete, execute SQL commands, and perform
other common database management tasks.
4. The [Link] class is used for database creation and
version management.
5. For performing any database operation, you have to provide the implementation of
onCreate() and onUpgrade() methods of SQLiteOpenHelper class.
Database Creation
In order to create a database you just need to call this method openOrCreateDatabase with
your database name and mode as a parameter. It
returns an instance of SQLite database which you have to receive in your own [Link]
syntax is given below
SQLiteDatabase mydatabase = openOrCreateDatabase(“your database
name”,MODE_PRIVATE,null);
d) Discuss Developer console with its purpose.
1. The Android Things Console provides easy and secure deployment of
updates to your connected devices.
2. Google provides the infrastructure to host and deliver system and app
updates with the developer in final control.
3. Using the console, developers and device makers can:
• Download and install the latest Android Things system image
• Build factory images that contain OEM applications along with the
system image
• Push over-the-air (OTA) seamless updates, including OEM
applications and the system image, to devices
• Manage and share OEM applications across products and owners
• Monitor informative analytics to understand how well products are
performing
Q 4 Attempt ant THREE of the following
a) Observe the following GUI and write an XML file using relative layout to
create the same
Ans:
<RelativeLayout
xmlns:android=”[Link]
android:layout_width=”fill_parent”
android:layout_height=”fill_parent” android:paddingLeft=”16dp”
android:paddingRight=”16dp” >
<EditText
android:id=”@+id/name”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content” />
<LinearLayout android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:layout_alignParentStart=”true”
android:layout_below=”@+id/name”
android:orientation=”horizontal”>
<EditText
android:id=”@+id/name”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content” />
<EditText
android:id=”@+id/name”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content” />
</LinearLayout>
<Button
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=”New Button”
android:id=”@+id/button” />
</RelativeLayout>
b) Write a program to display circular progress bar.
Ans: Xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ProgressBar
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/p1"/>
</LinearLayout>
Java file
package [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
ProgressBar myprogressbar;
int myprogress=0;
Thread mythread;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
myprogressbar=(ProgressBar)findViewById([Link].p1);
mythread=new Thread();
[Link]();
}
public void run()
{
while (myprogress<100)
{
try{
myprogress++;
[Link](myprogress);
[Link](100);
}
catch (Exception e)
{
}
}
}
}
c) List sensors in android and explain any one in detail
Ans: The Android platform supports three broad categories of sensors:
• Motion sensors
These sensors measure acceleration forces and rotational forces along three axes. This
category includes accelerometers, gravity sensors, gyroscopes, and rotational vector sensors.
• Environmental sensors
These sensors measure various environmental parameters, such as ambient air temperature
and pressure, illumination, and humidity. This category includes barometers, photometers,
and thermometers.
• Position sensors
These sensors measure the physical position of a device. This category includes orientation
sensors and magnetometers.
Android Sensors Types
• Photometer is used to sense and control the brightness. Besides, there are sensors for
pressure, humidity, and temperature.
• For movements, Accelerometer is used to detect shakes/tilt gestures.
• Proximity Sensors are used to detect how close the object is to the device. It’s commonly
present in Call Applications. As you bring the phone close to the ear, the screen goes black,
thanks to this sensor. Though the maximum range of proximity is 5 cms.
• Gyroscope is used to measure rotation/spin. Gravity sensors are used to measure the force
of gravity.
• Magneto Meter is used to get the device position.
• Pedometer is used to detect the number of steps the user takes.
d) Explain zoom control (IN/OUT) with help of an example
Ans: [Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MapsActivity extends FragmentActivity implements
OnMapReadyCallback {
GoogleMap mMap;
ZoomControls z1;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_maps);
// Obtain the SupportMapFragment and get
notified when the map is ready to be
used. SupportMapFragment mapFragment =
(SupportMapFragment)
getSupportFragmentManager() .findFragmen
tById([Link]);
[Link](this);
z1=findViewById([Link].z1);
[Link](new [Link]() {
@Override
public void onClick(View v) {
[Link]([Link]());
}
});
[Link](new [Link]() {
@Override
public void onClick(View v) {
[Link]([Link]());
}
});
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng nashik = new LatLng(19.99, 73.78);
[Link](new
MarkerOptions().position(nashik).tit
le("Marker in Sydney"));
[Link](CameraUpdate
[Link](nashik));
}
}
Android_Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="[Link]
[Link]/apk/res/
android" package="com.e
[Link]">
<uses-permission
android:name="[Link].ACCESS_FINE_LOCATION" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<meta-data
android:name="[Link].API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MapsActivity"
android:label="@string/title_activity_maps">
<intent-filter>
<action android:name="[Link]" />
<category
android:name="[Link]
[Link]"
/> </intent-filter>
</activity>
</application>
</manifest>
Activity_maps.xml
<?xml version="1.0" encoding="utf-8"?>
<fragment
xmlns:android="[Link]
[Link]/apk/res/a
ndroid" xmlns:map="http
://[Link]/ap
k/res-auto"
xmlns:tools="[Link]
android:id="@+id/map"
android:name="[Link]
[Link]
rtMapFragment" android:
layout_width="match_par
ent"
android:layout_height="match_parent"
tools:context=".MapsActivity" >
<ZoomControls
android:id="@+id/z1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</fragment>
Google_maps_api.xml
<resources>
<string name="google_maps_key" templateMergeStrategy="preserve"
translatable="false">AIzaSyDT5I1pBPfAqNeah5k9jD7OGczWGnfkMRo</string>
</resources>
e) Develop an application to send and receive SMS (write ONLY .java
and permission tag in manifest file)
Ans: Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="[Link]
android:orientation="vertical"
android:layout_width="match_parent" android:layout_height=
"match_parent">
<TextView
android:id="@+id/fstTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="150dp"
android:text="Mobile No" />
<EditText
android:id="@+id/mblTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:ems="10"/>
<TextView
android:id="@+id/secTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Message"
android:layout_marginLeft="100dp" />
<EditText
android:id="@+id/msgTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:ems="10" />
<Button
android:id="@+id/btnSend"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:text="Send SMS" />
</LinearLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
private EditText txtMobile;
private EditText txtMessage;
private Button btnSms;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
txtMobile = (EditText)findViewById([Link]);
txtMessage = (EditText)findViewById([Link]);
btnSms = (Button)findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
try{
SmsManager smgr = [Link]();
[Link]([Link]().toString(),null,[Link]().toString(
),n ull,null);
[Link]([Link], "SMS Sent Successfully",
Toast.LENGTH_SHORT).show();
}
catch (Exception e){
[Link]([Link], "SMS Failed to Send, Please try
again", Toast.LENGTH_SHORT).show();
}
}
});
[Link]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="[Link]
package=" [Link]">
<uses-permission android:name="[Link].SEND_SMS"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
Q.5) Attempt any TWO of the following.
a) Develop the registration form using the following GUI.
Ans:
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="@+id/img1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/gimg"
android:layout_marginLeft="90dp"
android:layout_marginTop="50dp"
android:layout_marginRight="90dp"
android:layout_marginBottom="600dp"
/>
<EditText
android:id="@+id/b1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="140dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:text="Name"
android:drawableLeft="@drawable/name"
/>
<EditText
android:id="@+id/b2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/b1"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:text="EmailID"
android:drawableLeft="@drawable/ic_baseline_email_24"/>
<EditText
android:id="@+id/b3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/b2"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:drawableLeft="@drawable/pass"
android:text="Password" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/b3"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:text="Confirm Password"
android:id="@+id/b4"
android:drawableLeft="@drawable/pass"
/>
<EditText
android:id="@+id/b5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/b4"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:text="Enter Moblie Number"
android:drawableLeft="@drawable/phone" />
<RadioButton
android:id="@+id/r1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/b5"
android:layout_marginLeft="100dp"
android:text="Male"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/r1"
android:layout_below="@id/b5"
android:layout_marginLeft="40dp"
android:text="Female"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/r1"
android:layout_marginLeft="100dp"
android:layout_marginRight="100dp"
android:text="Register" />
</RelativeLayout>
b) Write a program to capture an image using camera and display it.
Ans.
main_activity.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Take a Photo" >
</Button>
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@+id/button1"
android:layout_alignParentTop="true”>
</ImageView>
</RelativeLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
private static final int CAMERA_REQUEST=1888;
ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
imageView=(ImageView) [Link]([Link].imageView1);
Button photoButton=(Button) [Link]([Link].button1);
[Link](new [Link]() {
@Override
public void onClick(View v) {
Intent
cameraIntent=newIntent([Link].ACTION_IMAGE_CAPT
URE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST) {
Bitmap photo=(Bitmap) [Link]().get("data");
[Link](photo);
}
}
}
c) Develop a program to send an email.
Ans.
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="@+id/tV1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true
android:layout_marginLeft="90dp"
android:layout_marginTop="60dp"
android:text="DataFlair "
android:textColor="@color/colorPrimaryDark"
android:textSize="50dp" />
<EditText
android:id="@+id/textTo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Mail To" />
<EditText
android:id="@+id/textSubject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Subject:" />
<EditText
android:id="@+id/textMessage"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="top"
android:hint="Content:" />
<Button
android:id="@+id/buttonSend"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:text="Send" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="[Link]
package="[Link]">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category
android:name="[Link].L
AUNCHER"/> <action
android:name="[Link]
D" /> <category
android:name="[Link].D
EFAULT"/> <data
android:mimeType="message/rfc822"
/>
</intent-filter>
</activity>
</application>
</manifest>
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
private EditText mailTo;
private EditText mailSubject;
private EditText mailContent;
private Button subbtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
mailTo = (EditText) findViewById([Link]);
mailSubject = (EditText) findViewById([Link]);
mailContent = (EditText) findViewById([Link]);
subbtn = (Button) findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
Intent it = new Intent(Intent.ACTION_SEND);
[Link](Intent.EXTRA_EMAIL,
new
String[]{[Link]().toString(
)}); [Link](Intent.EXTRA_SU
BJECT,
[Link]().toString()); i
[Link](Intent.EXTRA_TEXT,
[Link]()); [Link]
("message/rfc822");
startActivity([Link]
ateChooser(it,
"Choose Mail
App")); }
});
}
}
Q.6) Attempt any TWO of the following.
a) Develop an application to store student details like roll no, name, branch,
marks, percentage and retrieve student information using roll no. in SQLite
databases.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center"
tools:context=".MainActivity">
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Enter the id"
android:id="@+id/t1"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="name"
android:id="@+id/t2"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="email"
android:id="@+id/t3"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Course"
android:id="@+id/t4"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Insert Record"
android:id="@+id/b1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/b2"
android:text="delete"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="get all data"
android:id="@+id/b3"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Update data"
android:id="@+id/b4"/>
</LinearLayout>
Main_Activity.java
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity {
Button b1,b2,b3,b4;
EditText t1,t2,t3,t4;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
b1=findViewById([Link].b1);
b2=findViewById([Link].b2);
b3=findViewById([Link].b3);
b4=findViewById([Link].b4);
t2=findViewById([Link].t2);
t3=findViewById([Link].t3);
t1=findViewById([Link].t1);
t4=findViewById([Link].t4);
[Link](new [Link]() {
@Override
public void onClick(View v) {
DBManager db=new DBManager([Link]);
String res=
[Link]([Link]().toString(),[Link]().toString(),[Link]().toString(
),[Link]
tText().toString());
[Link]([Link], res, Toast.LENGTH_SHORT).show();
[Link]("");
[Link]("");
[Link]("");
[Link]("");
}
});
[Link](new [Link]() {
@Override
public void onClick(View v) {
DBManager db=new DBManager([Link]);
Integer deleteddata=[Link]([Link]().toString());
if(deleteddata>0)
{
[Link]([Link], "deleted",
Toast.LENGTH_SHORT).show();
}
else
{
[Link]([Link], "Not Deleted",
Toast.LENGTH_SHORT).show();
}
}
});
[Link](new [Link]() {
@Override
public void onClick(View v) {
DBManager db=new DBManager([Link]);
Cursor res= [Link]();
if([Link]()==0)
{
showMessage("error","nothinng");
return;
}
StringBuffer str=new StringBuffer();
while([Link]())
{
[Link]("Id:="+[Link](0)+"\n");
[Link]("name:="+[Link](1)+"\n");
[Link]("email:="+[Link](2)+"\n");
[Link]("course:="+[Link](3)+"\n");
}
showMessage("Data",[Link]());
}
});
[Link](new [Link]() {
@Override
public void onClick(View v) {
DBManager db=new DBManager([Link]);
boolean
isupdate=[Link]([Link]().toString(),[Link]().toString(),[Link]
().toString()
,[Link]().toString());
if(isupdate==true)
{
[Link]([Link], "Data Updated",
Toast.LENGTH_SHORT).show();
}
else
{
[Link]([Link], "Data not Updated",
Toast.LENGTH_SHORT).show();
}
}
});
}
private void showMessage(String title, String message)
{
[Link] builder=new [Link](this);
[Link](true);
[Link](title);
[Link](message);
[Link]();
}
}
Create a new class for Database Operation
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class DBManager extends SQLiteOpenHelper {
private static final String dbname="[Link]";
public DBManager(@Nullable Context context) {
super(context, dbname, null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
String qry="create table pramila(id integer primary key ,name text,email
text,course
text)";
[Link](qry);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
[Link]("drop table if exists pramila");
onCreate(db);
}
public String addRecord(String p,String p1,String p2,String p3)
{
SQLiteDatabase db=[Link]();
ContentValues cv=new ContentValues();
[Link]("id",p);
[Link]("name",p1);
[Link]("email",p2);
[Link]("course",p3);
long res =[Link]("pramila",null,cv);
if(res==-1)
{
return "failed";
}
else
{
return "success";
}
}
public Cursor getAllData()
{
SQLiteDatabase db=[Link]();
Cursor res=[Link]("select * from "+"pramila",null);
return res;
}
public Integer deleteData(String id)
{
SQLiteDatabase db=[Link]();
return [Link]("pramila","Id=?",new String[] {id});
}
public boolean UpdateData(String pid,String pname,String pemail,String
pcourse)
{
SQLiteDatabase db=[Link]();
ContentValues cv=new ContentValues();
[Link]("id",pid);
[Link]("name",pname);
[Link]("email",pemail);
[Link]("course",pcourse);
[Link]("pramila",cv,"id=?",new String[] {pid});
return true;
}
}
b) Write a program to locate user’s current location. (Write ONLY .java
and manifest file)
Ans.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="[Link]">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Get Current Location"
android:id="@+id/getLocationBtn"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/locationText"
android:layout_below="@id/getLocationBtn"/>
</RelativeLayout>
[Link]
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="[Link]
package="[Link]">
<uses-permission
android:name="[Link].ACCESS_FINE_LOCATION" />
<uses-permission android:name="[Link]" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
25
Unit No:06 Mobile Application Development [Link]
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public class MainActivity extends AppCompatActivity implements
LocationListener {
Button getLocationBtn;
TextView locationText;
LocationManager locationManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
getLocationBtn = (Button)findViewById([Link]);
locationText = (TextView)findViewById([Link]);
[Link](new [Link]() {
@Override
public void onClick(View v) {
getLocation();
}
});
}
void getLocation() {
try {
locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
[Link](LocationManager.GPS_PROVIDER,
5000, 5, this);
}
catch(SecurityException e) {
[Link]();
}
}
@Override
public void onLocationChanged(Location location) {
[Link]("Current Location: " + [Link]() + ", " +
[Link]());
}
@Override
public void onProviderDisabled(String provider) {
26
Unit No:06 Mobile Application Development [Link]
[Link]([Link], "Please Enable GPS and Internet",
Toast.LENGTH_SHORT).show();
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@Override
public void onProviderEnabled(String provider) {
}
}
c) Develop a simple calculator using table layout.