lecture4
lecture4
ANDROID COMPONENTS
ANDROID APPLICATION COMPONENT
Application components are the essential building blocks
of an Android application.
These components are loosely coupled by the application
manifest file AndroidManifest.xml that describes each
component of the application and how they interact
There are following four main components that can be
used within an Android application −
ACTIVITIES
Activities
⚫ Can terminate itself via finish();
⚫ Can terminate other activities it started via
finishActivity();
Services
⚫ Can terminate via stopSelf(); or
Context.stopService();
Content Providers
⚫ Are only active when responding to ContentResolvers
Broadcast Receivers
⚫ Are only active when responding to broadcasts
ADDITIONAL COMPONENTS
INTENTS
An intent is an Intent object with a message content.
Activities, services and broadcast receivers are started by
intents. ContentProviders are started by
ContentResolvers:
⚫ An activity is started by Context.startActivity(Intent intent) or
Activity.startActivityForResult(Intent intent, int RequestCode)
⚫ A service is started by Context.startService(Intent service)
⚫ An application can initiate a broadcast by using an Intent in any
of Context.sendBroadcast(Intent intent),
Context.sendOrderedBroadcast(), and
Context.sendStickyBroadcast()
INTENT FILTERS
Declare Intents handled by the current application (in the
AndroidManifest):