Activity
- Hello World
- Demonstrates a basic screen activity.
- Code:
- HelloWorld.java
- Layout:
-
hello_world.xml
- Save & Restore State
- Demonstrates how an activity should save state when it is paused.
- Persistent State
- Demonstrates how you can save and restore preferences, which are stored
even after the user closes the application.
- Receive Result
- Demonstrates how an activity screen can return a result to the
activity that opened it.
- Forwarding
- Demonstrates opening a new activity and removing the current activity
from the history stack, so that when the user later presses BACK they will
not see the intermediate activity.
- Redirection
- Demonstrates how to save data to preferences and use it to determine
which activity to open next.
- Translucent
- Demonstrates how to make an activity with a transparent background.
- TranslucentBlur
- Demonstrates how to make an activity with a transparent background with
a special effect (blur).
Service
- Local Service Controller and
Local Service Binding
- Demonstrate the implementation of a service that runs in the same
process as its client(s). Shows how those clients can either start/stop it
with {@link android.content.Context#startService
Context.startService} and {@link android.content.Context#stopService
Context.stopService}, or bind and call it with
{@link android.content.Context#bindService Context.bindService} and
{@link android.content.Context#unbindService Context.unindService}.
This also shows how you can simplify working
with a service when you know it will only run in your own process.
- Remote Service Controller and
Remove Service Binding
- Demonstrates starting a service in a separate process, by assigning
android:process=":remote"
to the service in the
AndroidManifest.xml file. Shows how those clients can either start/stop it
with {@link android.content.Context#startService
Context.startService} and {@link android.content.Context#stopService
Context.stopService}, or bind and call it with
{@link android.content.Context#bindService Context.bindService} and
{@link android.content.Context#unbindService Context.unindService}.
Binding is similar to the local service sample,
but illustrates the additional work (defining aidl
interfaces) needed to interact with a service in another process. Also
shows how a service can publish multiple interfaces and implement
callbacks to its clients.
- Service Start Arguments Controller
- Demonstrates how you can use a Service as a job queue, where you
submit jobs to it with {@link android.content.Context#startService
Context.startService} instead of binding to the service. Such a service
automatically stops itself once all jobs have been processed. This can be
a very convenient way to interact with a service when you do not need
a result back from it.
- Foreground Service Controller
- Shows how you
can write a Service that runs in the foreground and works on both pre-2.0
and post-2.0 versions of the platform. This example will selectively use
the new foreground APIs that were introduced in Android 2.0 if they are
available.
Alarm
- Alarm Controller
- Demonstrates two ways you can schedule alarms: a one-shot alarm that
will happen once at a given time, and a repeating alarm that will happen
first at a given time and then continually trigger at regular intervals
after that.
- Code:
- AlarmController.java
- OneShotAlarm.java
- RepeatingAlarm.java
- Layout:
-
alarm_controller.xml
- Alarm Service
- Demonstrates how you can schedule an alarm that causes a service to
be started. This is useful when you want to schedule alarms that initiate
long-running operations, such as retrieving recent e-mails.
- Code:
- AlarmService.java
- AlarmService_Service.java
- Layout:
-
alarm_service.xml
Notification
- NotifyWithText
- Demonstrates popup notifications of varying length.
- IncomingMessage
- Demonstrates sending persistent and transient notifications, with a View object in the notification. It also demonstrated inflating a View object from an XML layout resource.
Search
- SearchInvoke
- Demonstrates various ways in which activities can launch the Search UI.
- SearchQueryResults
- Demonstrates an activity that receives Search intents and handles them.
- SearchSuggestionSampleProvider
- Demonstrates how to configure and use the built-in "recent queries" suggestion provider.