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