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