Sei sulla pagina 1di 46

UNIT 2

Building User
Interfaces
And ntents I
Prepared By : Chirag V. Rachchh

NJSMTI
For developing an Android application a
good knowledge of screen designing is vital.
Screen or layout is that part of our application
which the user will see and interact.

Intents are a very useful mechanism in


Android, it has many usages such as message
passing, starting activities, etc.
INTENTS AND
BROADCAST
RECEIVERS
Prepared By : Mr. Chirag V. Rachchh

NJSMTI
Introduction to Intents
Creating Intents
Creating Broadcast Receivers

NJSMTI
Intents are the most unique and
important feature of Android development.
We can use intents for tasks such as
starting activities, services, etc.

Using Broadcast intents we announce


events system wide.

While using Broadcast receivers


receive intents announced.
Introducing Intents

NJSMTI
Intents are used as message passing
mechanisms that works both within our
application and between applications.

More precisely, we can use intent for


Explicitly starting a service or activity
Starting an activity or service to perform an action
on a particular piece of data
Broadcasting that an event has occur
Creating Intent
Filters and
Broadcast Receivers

NJSMTI
As we have already discussed intents
are also used to broadcast events.

We can add necessary mechanism to


receive the broadcasted intents. If our
application want to listen for broadcasted
intents, it need to become broadcast
receiver.
an intent is a
request for an action to be performed on a set of
data an Intent filter is a declaration that a
particular application is capable of performing an
action on a type of data
Using Intent Filter

NJSMTI
action tag
uses the android:name attribute to specify
the name of the action being serviced. Each
Intent-filter must have at least one action
tag.
Category
uses the android:name attribute to specify
under which circumstances the action
should be serviced.
Each intent filter tag can include multiple
category tags. Following are the standard
values for this tag
ALTERNATIVE
SELECTED ALTERNATIVE
BROWSABLE
DEFAULT
HOME
LAUNCHER
data tag
Used to specify the data type on which the
component can act on.
The possible values for data tag
android:host
android:mimetype
android:path
android:port
android:scheme
Intent intent=getIntent();
String action=intent.getAction();
Uri data=intent.getData();
Intent intent=getIntent();
startNextMatchingActivity(intent);
Broadcast Receiver

NJSMTI
Update content
Launch services
Update Activity UI
Notify the user
onResume()
onPause()
ACTION_BOOT_COMPLETED
ACTION_CAMERA_BUTTON
ACTION_DATE_CHANGED
ACTION_MEDIA_EJECT
ACTION_NEW_OUTGOING_CALL
ACTION_SCREEN_OFF
ACTION_TIMEZONE_CHANGED
Intent.ACTION_BATTERY_CHANGED
android.net.conn.CONNECTIVITY_CHANGE
android.intent.action.ACTION_DOCK_EVENT
BROADCAST_STICKY

Potrebbero piacerti anche