| page.title=Running in a Background Service |
| page.tags=intentservice |
| |
| trainingnavtop=true |
| startpage=true |
| |
| @jd:body |
| |
| <div id="tb-wrapper"> |
| <div id="tb"> |
| <h2>Dependencies and prerequisites</h2> |
| <ul> |
| <li>Android 1.6 (API Level 4) or higher</li> |
| </ul> |
| <h2>You should also read</h2> |
| <ul> |
| <li> |
| <a href="{@docRoot}guide/components/services.html#ExtendingIntentService">Extending the IntentService Class</a> |
| </li> |
| <li> |
| <a href="{@docRoot}guide/components/intents-filters.html">Intents and Intent Filters</a> |
| </li> |
| </ul> |
| <h2>Try it out</h2> |
| |
| <div class="download-box"> |
| <a href="{@docRoot}shareables/training/ThreadSample.zip" class="button">Download the sample</a> |
| <p class="filename">ThreadSample.zip</p> |
| </div> |
| |
| </div> |
| </div> |
| <!-- ------------------------------------------------------------------------------------------- --> |
| <!-- Introduction --> |
| <!-- ------------------------------------------------------------------------------------------- --> |
| <p> |
| Unless you specify otherwise, most of the operations you do in an app run in the foreground on |
| a special thread called the UI thread. Long-running foreground operations can cause problems |
| and interfere with the responsiveness of your user interface, which annoys your users and can |
| even cause system errors. To avoid this, the Android framework offers several classes that |
| help you off-load operations onto a separate thread that runs in the background. The most |
| useful of these is {@link android.app.IntentService}. |
| </p> |
| <p> |
| This class describes how to implement an {@link android.app.IntentService}, send it work |
| requests, and report its results to other components. |
| </p> |
| |
| <p class="note"><strong>Note:</strong> If your app targets Android 5.0 (API level 21), |
| you should use {@link android.app.job.JobScheduler} to execute background |
| services. For more information about this class, |
| see the {@link android.app.job.JobScheduler} reference documentation.</p> |
| |
| <h2>Lessons</h2> |
| <dl> |
| <dt> |
| <b><a href="create-service.html">Creating a Background Service</a></b> |
| </dt> |
| <dd> |
| Learn how to create an {@link android.app.IntentService}. |
| </dd> |
| <dt> |
| <b><a href="send-request.html">Sending Work Requests to the Background Service</a></b> |
| </dt> |
| <dd> |
| Learn how to send work requests to an {@link android.app.IntentService}. |
| </dd> |
| <dt> |
| <b><a href="report-status.html">Reporting Work Status</a></b> |
| </dt> |
| <dd> |
| Learn how to use an {@link android.content.Intent} and a |
| {@link android.support.v4.content.LocalBroadcastManager} to communicate the status of a |
| work request from an {@link android.app.IntentService} to the |
| {@link android.app.Activity} that sent the request. |
| </dd> |
| </dl> |
| |