Top Banner
Android Components Vivek Nadar
11

Android+building+blocks.ppt

Apr 13, 2015

Download

Documents

Guneet Garg

Android building blocks
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Android+building+blocks.ppt

Android Components

Vivek Nadar

Page 2: Android+building+blocks.ppt

Application ComponentsApplication Components

There are 4 types of application components

(1) Activities – visual user interface focused

on a single thing a user can do

(2) Services – no visual interface –

they run in the background

(3) Broadcast Receivers –

receive and react to broadcast announcements

(4) Content Providers –

allow data exchange between applications

Page 3: Android+building+blocks.ppt

What is an Activity ? An Activity means a single screen with a user interface. An application usually consists of multiple activities

that are loosely bound to each other. Activity generally provides a user with an interactive screen to do

something like:

Dialing the phone, Viewing a map, etc. Every screen in an application,is an activity by itself.

Page 4: Android+building+blocks.ppt

Intents

Intents are used as a message-passing mechanism, that works both within application and between applications.

Two types of Intents:

1) Implicit Implicit does not specify a component. Instead,it includes enough information for

the system to determine which of the available components is best to run for that intent.

Example : Intent webIntent = new

Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com")); startActivity(webIntent);

Page 5: Android+building+blocks.ppt

Intents...(2)2) Explicit Intents

Explicit Intents explicitly defines the component which should be called by the Android system, by using the Java class as identifier.

e.g. Intent launchExplicitIntent = new Intent(this,Game.class);

startActivity(launchExplicitIntent);

Page 6: Android+building+blocks.ppt

Program Demo

Page 7: Android+building+blocks.ppt

2. Services A Task that runs in the background without the user's direct interaction. A service does not have a visual user interface. A service,by default runs in the main thread of the application

that hosts it. Examples

Network Downloads Playing Music Checking updates for an application

Page 8: Android+building+blocks.ppt

Program Demo

Page 9: Android+building+blocks.ppt

3. Broadcast receiver

A Broadcast receiver is a component that responds to system-wide Broadcast announcements.

Many broadcasts originate from the system - for e.g. a Broadcast announcing that thescreen has turned off, the battery is low,a picture was captured or an SMS is received.

Page 10: Android+building+blocks.ppt

Broadcast receiver...(2)

An Application can also initiate broadcast

for e.g.to let other Applications know that

some data has been downloaded to the device

and is available for those application to use.

It creates a status bar notification to alert the user when a broadcast event occurs.

Page 11: Android+building+blocks.ppt

4. Content Providers

Shared set of data. Makes some of the application data

available to other applications It is the only way to transfer data between applications in

Android (no shared files,

no shared memory,no pipes, etc.)