• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<p>
2    This sample is a revised version of the AlarmService functionality included in the
3    ApiDemos sample application. It is used as the application under test
4    for the <a href="../AlarmServiceTest/index.html">Alarm Service Test</a>
5    sample test application.
6</p>
7<p>
8    This application demonstrates a simple Android service that is started when needed by
9    <code>Context.startService(Intent)</code> and stops itself when its work is done. You can
10    use this type of service to move long-running or periodic tasks into the background. For
11    example, you could use this type of service to perform data synchronization.
12</p>
13<p>
14    In the sample, the service simply runs for 15 seconds and then stops itself. The wait is
15    implemented in a separate thread that uses a thread-safe object. This illustrates how to
16    set up a service that runs multiple threads that depend on one or more objects that must be
17    made thread-safe.
18</p>
19<p>
20    The application also contains the <code>AlarmActivity</code> activity that is a client of the
21    service. You use the activity to control when the service starts and stops. By default, the
22    activity fires off the service every thirty seconds. In effect, the service starts after
23    thirty seconds, runs for 15 seconds, stops, and then runs again automatically in another
24    15 seconds. You also use the client to stop this cycle.
25</p>
26<p>
27    The test application <a href="tests/index.html">AlarmServiceTest</a>
28    shows you how to set up a test of this service.
29</p>
30