0% found this document useful (0 votes)
26 views15 pages

Lecture No 06 Building Blocks of Android Application

Building Blocks of Android Application

Uploaded by

Mian Haider
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views15 pages

Lecture No 06 Building Blocks of Android Application

Building Blocks of Android Application

Uploaded by

Mian Haider
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Mobile Application

Development
Building Blocks of Android Application
Building Blocks of Android Application

• Activities
• Services
• Content Providers
• Intents
• Broadcast Receivers
• Widgets
• Notifications
2
Activities

• Your application’s presentation layer.

• Every screen in your application will be an extension


of the Activity class.

• Activities use Views to form graphical user interfaces


that display information and respond to user actions.

3
Activities (Cont.)

• An Activity comprises the visual components (“views”)


for one screen as well as the code that displays data
into that screen and can respond to user events on
that screen.

• Almost every application has at least one Activity


class.

4
Activities (Cont.)

Same Activity

5
Activities (Cont.)

Different Activities

6
Activities (Cont.)

• A different app can start


any one of these
activities. For example,
another app can start
the activity in the email
app that composes new
mail.

7
Services

• The invisible workers of your application.


• Service components run invisibly, updating your data
sources and visible Activities and triggering Notifications.
• They’re used to perform regular processing that needs to
continue even when your application’s Activities aren’t
active or visible.
• For example, play music in the background while the user
is in a different app, or it might fetch data over the
network.
8
Content Providers

• A shareable data store.


• Content Providers are used to manage and share
application databases.
• Content Providers are the preferred way of sharing
data across application boundaries.
• Contact Manager

9
Content Providers

• You can store the data in the file system, an SQLite


database, on the web, or any other persistent storage
location your app can access.

• Through the content provider, other apps can query or


even modify the data (if the content provider allows
it).

10
Content Providers (Cont.)

• For example, the Android system


provides a content provider that
manages the user's contact information.

• As such, any app with the proper


permissions can query part of the
content provider to read and write
information about a particular person.

11
Intents

• A simple message-passing framework.


• Using Intents, you can broadcast messages system-
wide or to a target Activity or Service, stating your
intention to have an action performed.
• The system will then determine the target(s) that will
perform any actions as appropriate.

12
Broadcast Receivers

• A broadcast receiver is a component that responds to


system-wide broadcast announcements.
• Broadcast receivers don't display a user interface, but in
some cases a status bar notification is created to alert the
user when a broadcast event occurs.
• For example, a broadcast announcing that the screen has
turned off, the battery is low, or a picture was captured.
• Although Apps can also initiate broadcasts, many
broadcasts also originate from the system
13
Notifications

• A user notification framework.


• Notifications let you signal users without stealing
focus or interrupting their current Activities.
• They’re the preferred technique for getting a user’s
attention from within a Service or Broadcast Receiver.
• For example, when a device receives a text message
or an incoming call, it alerts you by flashing lights,
making sounds, displaying icons, or showing dialog
messages. 14
Activating Components
• Three of the four component types—Activities, Services, and Broadcast Receivers—
are activated by an asynchronous message called an intent.
• Intents bind individual components to each other at runtime,whether the
component belongs to your app or another.
• For activities and services, an intent defines the action to perform (for example, to
"view" or "send" something) . For example, an intent might convey a request for an
activity to show an image or to open a web page.
• For broadcast receivers, the intent simply defines the announcement being
broadcast (for example, a broadcast to indicate the device battery is low includes
only a known action string that indicates "battery is low").
• Content Provider is activated (not by Intent) when targeted by a request from a
ContentResolver - handles all direct transactions between the content provider and
the component requesting information (for security).
15

You might also like