0% found this document useful (0 votes)
31 views5 pages

Question Bank Unit Test 2

The document discusses various Android concepts like sending SMS, location services, Google Maps, permissions, activity lifecycle, intents, fragments, services, content providers. It provides details on classes, methods, and lifecycles related to these concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views5 pages

Question Bank Unit Test 2

The document discusses various Android concepts like sending SMS, location services, Google Maps, permissions, activity lifecycle, intents, fragments, services, content providers. It provides details on classes, methods, and lifecycles related to these concepts.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

MAD Chapter 6th Notes:

In android, we can send SMS from our android application in two ways either by using
SMSManager API or Intents based on our requirements.
If we use SMSManager API, it will directly send SMS from our application. In case if we use Intent with proper
action (ACTION_VIEW), it will invoke a built-in SMS app to send SMS from our application.

Classes of SMS Telephony


1. Telephony.Sms.Conversations
2. Telephony.Sms.Draft
3. Telephony.Sms.Inbox
4. Telephony.Sms.Intents
5. Telephony.Sms.Outbox
6. Telephony.Sms.Sent
6.2 Location Based Services
Location Based Services are provided by Android through its location framework. The framework provides a location
API which consists of certain classes and interface. These classes and interface are the key components which allow
us to develop Location Based Application in Android.
Classes and Interfaces of Location Based Services:
LocationManager – This class helps to get access to the location service of the system.
LocationListener – This interface acts as the listener which receives notification from the location manager when the
location changes or the location provider is disabled or enabled.
Location – This is the class which represents the geographic location returned at a particular time.

Android Google Map


Android provides facility to integrate Google map in our application. Google map displays your current location,
navigate location direction, search location etc.
Types of Google Maps
Normal: This type of map displays typical road map, natural features like river and some features build by humans.
2. Hybrid: This type of map displays satellite photograph data with typical road maps. It also displays road and
feature labels.
3. Satellite: Satellite type displays satellite photograph data, but doesn't display road
and feature labels.
4. Terrain: This type displays photographic data. This includes colors, contour lines and labels and perspective
shading.
5. None: This type displays an empty grid with no tiles loaded.
Syntax of different types of map
1. googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
Methods of Google map
addCircle(),addPolygon(),animateCamera():moves the map according to the upgradation in the animation
Clear():clears everything from the map stopAnimation():stops the camera animation if it is in progress,
getMyLocation():used to retrive current location.
Getting the maps API key
Step 1: Open Google developer console and signin with your gmail
account: https://console.developers.google.com/project
Step 2: click on the Create Project button and give name to your project.
Step 3:APIs & Services and open Dashboard from it.
Step 4:Enable APIS AND SERICES.
Step 5: Google Map Android API
Step 6: Now enable the Google Maps Android API
Step 6: go to Credentials
Step 7: click on Create credentials and choose API key
Step 8: Now API your API key will be generated. Copy it and save it somewhere as we
will need it when implementing Google Map in our Android project.

Permissions for Google Maps:


INTERNET, ACCESS_COARSE_LOCATION,ACCESS_FINE_LOCATION
Geocoding is the process of converting addresses (like a street address) into geographic coordinates (like latitude and
longitude), which you can use to place markers on a map, or position the map.
Reverse geocoding is the process of converting geographic coordinates into a humanreadable address.
Geocoding is the process of finding the geographical coordinates (latitude and longitude) \of a given address or
location. Reverse Geocoding is the opposite of geocoding where a pair of latitude and longitude is converted into an
address or location. For achieving Geocode or Reverse Geocode you must first import the proper package.
import android.location.Geocoder;

Getting Location data


There are two types of location providers,
1. GPS Location Provider
2. Network Location Provider
Network Location provider is comparatively faster than the GPS provider in providing the location co-ordinates.
• GPS provider may be very very slow in in-door locations and will drain the mobile battery.
• Network location provider depends on the cell tower and will return our nearest tower location.
• GPS location provider, will give our location accurately.

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).
Permissions are divided into several protection levels.
There are three protection levels that affect third-party apps: normal, signature, and dangerous permissions.
Normal Permissions: These types of permissions are not risky for the users and the system. Sometimes the system
automatically grants to this type of permission eg:VIBRATE,SET_WALLPAPER,SET_ALARM
Signature permissions:Android system gives these permissions during the installation.
eg:READ_VOICEMAILS,WRITE_VOICEMAILS
Dangerous permissions:Permissions that are dangerous that can affect users data in some way are the dangeours
permissions. CAMERA,SEND_SMS,RECEIVE_SMS

Unit-V Activity and Multimedia with Databases


Intent is an object used to start operation or sends data sets to another components. Used for communication between
the android application components or between one application to another applications.
Syntax:
Intent intent = new Intent(getApplicationContext(), SecondActivity.class);
startActivity(intent);

There are two types of Intents: Implict :Establishes connection between application to application
Explicit:between activity to activity.

Intent Filer:Intent Filter are the components which decide the behavior of an intent.
Intent filters specify the type of intents that an Activity, service or Broadcast receiver can respond to.
There are following three elements in an intent filter:
1. Action :what an activity is going to do.
2. Data :allows to pass the data
3. Category: decides behavior or nature of an Intent.

Activity Lifecycle: Activity is one of the building blocks of Android OS.


onCreate() – Called when the activity is first created
onStart() – Called just after it’s creation or by restart method after onStop(). Here Activity start becoming visible to
user.
onResume() – Called when Activity is visible to user and user can interact with it
onPause() – Called when Activity content is not visible because user resume previous activity
onStop() – Called when activity is not visible to user because some other activity takes place of it
onRestart() – Called when user comes on screen or resume the activity which was stopped
onDestroy – Called when Activity is not in background

In android, Broadcast Receiver is a component which will allow android system or other apps to deliver events to the
app like sending a low battery message or screen turned off message to the app.

In android, Content Provider will act as a central repository to store the applications data in one place and make that
data available for different applications to access whenever it’s required.
query() - It receives a request from the client. By using arguments it will get a data from requested table and return
the data as a Cursor object.
insert() - This method will insert a new row into our content provider and it will return the content URI for newly
inserted row.
update() - This method will update an existing rows in our content provider and it return the number of rows updated.
delete() - This method will delete the rows in our content provider and it return the
number of rows deleted.
getType() - This method will return the MIME type of data to given content URI.
onCreate() - This method will initialize our provider. The android system will call this
method immediately after it creates our provider.

Fragment:Part of the Activity also known as sub-activity. An activity can contain multiple of fragments
Service: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 is an android component with UI
There can be two forms of a service.The lifecycle of service can follow two different paths:
started or bound.
1. Started
2. Bound
1) Started Service
A service is started when component (like activity) calls startService() method, now it runs in the background
indefinitely. It is stopped by stopService() method. The service can stop itself by calling the stopSelf() method.
2) Bound Service
A service is bound when another component (e.g. client) calls bindService() method. The client can unbind the
service by calling the unbindService() method.
The service cannot be stopped until all clients unbind the service.
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.
onStartCommand()
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.
onBind()
This is invoked when any component starts the service by calling onBind.
onUnbind()
This is invoked when all the clients are disconnected from the service.
onRebind()
This is invoked when new clients are connected to the service. It is called after onUnbind
onDestroy()
This is a final clean up call from the system. This is invoked just before the service is being destroyed. Could be very
useful to cleanup any resources such as threads, registered listeners, or receivers.

You might also like