2 Marks
1. State the uses of Intent in Android. (W22)
An Intent is a messaging object you can use to request an action from another
app component.Intents are used for facilitating communication between
components like Activities, Services and Broadcast Receivers.
2. Explain significance of content provider. (W22)
Content Providers are used to share data between two applications. This can be
implemented in two ways:
1. When you want to implement the existing content provider in another
application.
2. When you want to create a new content provider that can share its data with
other Applications
3. State syntax to display built in zoom control. (S22)
a) Built in Zoom control in Google map can be displayed with :
UiSettings.setZoomControlsEnabled(true);
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 ranges from 0 to 21.
OR
c) In any normal activity, ZoomControl can be displayed as component by
following
syntax :
ZoomControl zoomControls = (ZoomControls)
findViewById(R.id.simpleZoomControl); zoomControls.show()
4. Name two classes used to play audio and video in Android. (S22)
1) MediaPlayer 2) MediaController 3) AudioManager
5. State intent. List types of intent.(W23)
Intent is the message that is passed between components such as activities.
Android uses Intent for communicating between the components of an
Application and also from one application to another application.
Types:
Explicit Intent
Implicit Intent
6. Define :
i) Fragment : Fragment is the part of activity, it is also known as sub-activity.
ii) Broadcast receiver: A broadcast receiver is a dormant component of the
Android system. The Broadcast Receiver’s job is to pass a notification to the user,
in case a specific event occurs.
7. State the use of fragments in android App development.(S23)
Android Fragment is the part of activity; it is also known as sub-activity. There
can be more than one fragment in an activity.
Fragments represent multiple screens inside one activity.
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. 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.
8. List different types of sensors used in android.(S23)
The android platform supports three broad categories of sensors.
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 :- These are used to measure the physical position of device.
6 Marks
1) Explain the activity life cycle.(Samp),(W22),(W23),(S24)
Activities have a predefined life-cycle methods as follows:
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.
5) Elaborate the need of permissions in Android. Explain the permissions to set
system functionalities like SEND-SMS, bluetooth. (W22)
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.
android. permission. SEND_SMS
Allows the app to send SMS messages. This may result in unexpected charges.
Malicious apps may cost you money by sending messages without your
confirmation. Following is the code snippet to set SEND_SMS permissions in
manifest file.
<uses-permission android: name="android.permission.SEND_SMS"/>
android. permission. BLUETOOTH
You need to provide following permissions in AndroidManifest.xml file.
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
6) Describe with ex, how to create a simple database in SQLite (S22)
This procedure is by openOrCreateDatabase()
1. The package imported into the application is
android.database.sqlite.SQLiteDatabase.
2. Here the class used is SQLiteDatabase.
3. The method used to create the database or connect to the database is
openOrCreateDatabse() method.
Program:
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">
<Button
android:text="Create SQLite Database"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:id="@+id/button" />
</RelativeLayout>
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;;
public class MainActivity extends AppCompatActivity {
SQLiteDatabase sqLiteDatabaseObj;
Button EnterData;
@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);
} });
}
7) Describe permissions required for android application development./
Describe types of permissions used while developing android
application.(S24)(S23)
The Android security model is primarily based on a sandbox and permission
mechanism. 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.