2. Android Components
There are 4 basic components of an Android
Application :
ï Activity
ï Service
ï Broadcast Receiver
ï Content Provider
http://aatul.me - Atul Palandurkar
3. Activity
ï An Activity represents a single screen with UI.
ï Activity class takes care of creating a window in
which UI can be placed with the method
setContentView(View)
ï While activities are often presented as full screen
windows, they can also be used as floating
windows or embedded inside another activity.
ï The onCreate(Bundle) is where you initialize your
activity.
ï All activity classes must have a corresponding
<activity> declaration in their packageâs
AndroidManifest.xml
http://aatul.me - Atul Palandurkar
6. Service
ïA Service is a component that runs in the
background to perform long-running operations or
to perform wok for remote processes.
ï Each service class must have a corresponding
<service> declaration in its packageâs
AndroidManifest.xml
ï A service does not provide user interface.
ï Another component, such as an activity, can start
the service and let it run or bind to it in order to
interact with it.
http://aatul.me - Atul Palandurkar
7. startService()
Service Starts the service
Life Cycle onStartCommand()
Starts actual operation
Context.bindService()
Obtains data from persistent
onStop()
OR
Context.stopService()
Stops the service, ready to get destroyed
onDestroy()
http://aatul.me - Atul Palandurkar
8. Broadcast Receiver
ï They listen to broadcast intents.
ï They must be registered (either in code or within the
AndroidManifest.xml).
ï Intent Filters must be used to specify which Intents it
is listening for.
ï A broadcast receiver can be registered using
multiple intent filters.
ï The onReceive() method be overridden to perform
any operations.
http://aatul.me - Atul Palandurkar
9. Content Provider
ï Content providers are one of the primary building
blocks of Android applications, providing content
to applications.
ï They encapsulate data & provide it to applications
through a single interface called ContentResolver.
ï A content provider is only required if there us a
need to share data between multiple applications.
ï For example, the contacts data is used by multiple
applications & must be stored in a content
provider.
http://aatul.me - Atul Palandurkar
10. Thank You
Atul Palandurkar
Blog : http://aatul.me
Training : training@shardainfotech.com
Website : http://shardainfotech.com
Contact : 091-9766210353