Joe Malin | f0f5efb | 2012-10-27 11:16:19 -0700 | [diff] [blame] | 1 | page.title=Running in a Background Service |
Joe Fernandez | 33baa5a | 2013-11-14 11:41:19 -0800 | [diff] [blame] | 2 | page.tags=intentservice |
Scott Main | 1c2dea0 | 2013-04-10 18:59:29 -0700 | [diff] [blame] | 3 | |
Joe Malin | f0f5efb | 2012-10-27 11:16:19 -0700 | [diff] [blame] | 4 | trainingnavtop=true |
| 5 | startpage=true |
Scott Main | 1c2dea0 | 2013-04-10 18:59:29 -0700 | [diff] [blame] | 6 | |
Joe Malin | f0f5efb | 2012-10-27 11:16:19 -0700 | [diff] [blame] | 7 | @jd:body |
Scott Main | 1c2dea0 | 2013-04-10 18:59:29 -0700 | [diff] [blame] | 8 | |
Joe Malin | f0f5efb | 2012-10-27 11:16:19 -0700 | [diff] [blame] | 9 | <div id="tb-wrapper"> |
| 10 | <div id="tb"> |
| 11 | <h2>Dependencies and prerequisites</h2> |
| 12 | <ul> |
| 13 | <li>Android 1.6 (API Level 4) or higher</li> |
| 14 | </ul> |
| 15 | <h2>You should also read</h2> |
| 16 | <ul> |
| 17 | <li> |
| 18 | <a href="{@docRoot}guide/components/services.html#ExtendingIntentService">Extending the IntentService Class</a> |
| 19 | </li> |
| 20 | <li> |
| 21 | <a href="{@docRoot}guide/components/intents-filters.html">Intents and Intent Filters</a> |
| 22 | </li> |
| 23 | </ul> |
| 24 | <h2>Try it out</h2> |
| 25 | |
| 26 | <div class="download-box"> |
| 27 | <a href="{@docRoot}shareables/training/ThreadSample.zip" class="button">Download the sample</a> |
| 28 | <p class="filename">ThreadSample.zip</p> |
| 29 | </div> |
| 30 | |
| 31 | </div> |
| 32 | </div> |
| 33 | <!-- ------------------------------------------------------------------------------------------- --> |
| 34 | <!-- Introduction --> |
| 35 | <!-- ------------------------------------------------------------------------------------------- --> |
| 36 | <p> |
| 37 | Unless you specify otherwise, most of the operations you do in an app run in the foreground on |
| 38 | a special thread called the UI thread. This can cause problems, because long-running operations |
| 39 | will interfere with the responsiveness of your user interface. This annoys your users, and can |
| 40 | even cause system errors. To avoid this, the Android framework offers several classes that |
| 41 | help you off-load operations onto a separate thread running in the background. The most useful |
| 42 | of these is {@link android.app.IntentService}. |
| 43 | </p> |
| 44 | <p> |
| 45 | This class describes how to implement an {@link android.app.IntentService}, send it work |
| 46 | requests, and report its results to other components. |
| 47 | </p> |
| 48 | <h2>Lessons</h2> |
| 49 | <dl> |
| 50 | <dt> |
| 51 | <b><a href="create-service.html">Creating a Background Service</a></b> |
| 52 | </dt> |
| 53 | <dd> |
| 54 | Learn how to create an {@link android.app.IntentService}. |
| 55 | </dd> |
| 56 | <dt> |
| 57 | <b><a href="send-request.html">Sending Work Requests to the Background Service</a></b> |
| 58 | </dt> |
| 59 | <dd> |
| 60 | Learn how to send work requests to an {@link android.app.IntentService}. |
| 61 | </dd> |
| 62 | <dt> |
| 63 | <b><a href="report-status.html">Reporting Work Status</a></b> |
| 64 | </dt> |
| 65 | <dd> |
| 66 | Learn how to use an {@link android.content.Intent} and a |
| 67 | {@link android.support.v4.content.LocalBroadcastManager} to communicate the status of a |
| 68 | work request from an {@link android.app.IntentService} to the |
| 69 | {@link android.app.Activity} that sent the request. |
| 70 | </dd> |
| 71 | </dl> |
| 72 | |