Android Building Blocks
Android Building Blocks
Android Building Blocks
Vivek Nadar
Application 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
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.
Intents
Intents are used as a message-passing mechanism, that works both within application and between applications. Two types of Intents: 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.
1) Implicit
Example :
Intent webIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.google.com")); startActivity(webIntent);
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);
Program Demo
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 Examples Network Downloads Playing Music Checking updates for an application
Program Demo
3. Broadcast receiver
Many broadcasts originate from the system - for e.g. a Broadcast announcing that the screen has turned off, the battery is low, a picture was captured or an SMS is received.
Broadcast receiver...(2)
It creates a status bar notification to alert the user when a broadcast event occurs.
4. Content Providers