Lines Matching refs:Service

12 <li><a href="#CreatingAService">Creating a Started Service</a>
15 <li><a href="#ExtendingService">Extending the Service class</a></li>
20 <li><a href="#CreatingBoundService">Creating a Bound Service</a></li>
22 <li><a href="#Foreground">Running a Service in the Foreground</a></li>
23 <li><a href="#Lifecycle">Managing the Lifecycle of a Service</a>
32 <li>{@link android.app.Service}</li>
52 <p>A {@link android.app.Service} is an application component that can perform
82 android.app.Service#onStartCommand onStartCommand()} to allow components to start it and {@link
83 android.app.Service#onBind onBind()} to allow binding.</p>
124 <p>To create a service, you must create a subclass of {@link android.app.Service} (or one
130 <dt>{@link android.app.Service#onStartCommand onStartCommand()}</dt>
135 its work is done, by calling {@link android.app.Service#stopSelf stopSelf()} or {@link
138 <dt>{@link android.app.Service#onBind onBind()}</dt>
144 <dt>{@link android.app.Service#onCreate()}</dt>
146 procedures (before it calls either {@link android.app.Service#onStartCommand onStartCommand()} or
147 {@link android.app.Service#onBind onBind()}). If the service is already running, this method is not
149 <dt>{@link android.app.Service#onDestroy()}</dt>
157 android.app.Service#onStartCommand onStartCommand()}), then the service
158 remains running until it stops itself with {@link android.app.Service#stopSelf()} or another
163 android.app.Service#onStartCommand onStartCommand()} is <em>not</em> called), then the service runs
176 android.app.Service#onStartCommand onStartCommand()}, as discussed later). For more information
223 your {@link android.app.Service}</strong> and do not declare intent filters for the service. If
239 <h2 id="CreatingStartedService">Creating a Started Service</h2>
243 {@link android.app.Service#onStartCommand onStartCommand()} method.</p>
248 is done by calling {@link android.app.Service#stopSelf stopSelf()}, or another component can stop it
254 this {@link android.content.Intent} in the {@link android.app.Service#onStartCommand
260 android.app.Service#onStartCommand onStartCommand()}, connects to the Internet and performs the
272 <dt>{@link android.app.Service}</dt>
278 <dd>This is a subclass of {@link android.app.Service} that uses a worker thread to handle all
299 android.app.Service#onStartCommand onStartCommand()} separate from your application's main
305 {@link android.app.Service#stopSelf}.</li>
375 the base {@link android.app.Service} class, which is a lot more code, but which might be
379 <h3 id="ExtendingService">Extending the Service class</h3>
384 can extend the {@link android.app.Service} class to handle each intent.</p>
387 android.app.Service} class that performs the exact same work as the example above using {@link
392 public class HelloService extends Service {
461 <p>However, because you handle each call to {@link android.app.Service#onStartCommand
466 <p>Notice that the {@link android.app.Service#onStartCommand onStartCommand()} method must return an
470 from {@link android.app.Service#onStartCommand onStartCommand()} must be one of the following
474 <dt>{@link android.app.Service#START_NOT_STICKY}</dt>
475 <dd>If the system kills the service after {@link android.app.Service#onStartCommand
479 <dt>{@link android.app.Service#START_STICKY}</dt>
480 <dd>If the system kills the service after {@link android.app.Service#onStartCommand
482 android.app.Service#onStartCommand onStartCommand()}, but <em>do not</em> redeliver the last intent.
483 Instead, the system calls {@link android.app.Service#onStartCommand onStartCommand()} with a
487 <dt>{@link android.app.Service#START_REDELIVER_INTENT}</dt>
488 <dd>If the system kills the service after {@link android.app.Service#onStartCommand
490 android.app.Service#onStartCommand onStartCommand()} with the last intent that was delivered to the
499 <h3 id="StartingAService">Starting a Service</h3>
504 android.app.Service#onStartCommand onStartCommand()} method and passes it the {@link
505 android.content.Intent}. (You should never call {@link android.app.Service#onStartCommand
518 the Android system calls the service's {@link android.app.Service#onStartCommand
520 android.app.Service#onCreate onCreate()}, then calls {@link android.app.Service#onStartCommand
532 {@link android.app.Service#onStartCommand onStartCommand()}. However, only one request to stop
533 the service (with {@link android.app.Service#stopSelf stopSelf()} or {@link
541 continues to run after {@link android.app.Service#onStartCommand onStartCommand()} returns. So,
542 the service must stop itself by calling {@link android.app.Service#stopSelf stopSelf()} or another
545 <p>Once requested to stop with {@link android.app.Service#stopSelf stopSelf()} or {@link
550 android.app.Service#onStartCommand onStartCommand()} concurrently, then you shouldn't stop the
553 this problem, you can use {@link android.app.Service#stopSelf(int)} to ensure that your request to
555 android.app.Service#stopSelf(int)}, you pass the ID of the start request (the <code>startId</code>
556 delivered to {@link android.app.Service#onStartCommand onStartCommand()}) to which your stop request
558 android.app.Service#stopSelf(int)}, then the ID will not match and the service will not stop.</p>
565 android.app.Service#onStartCommand onStartCommand()}.</p>
568 href="#Lifecycle">Managing the Lifecycle of a Service</a>.</p>
572 <h2 id="CreatingBoundService">Creating a Bound Service</h2>
584 android.app.Service#onBind onBind()} callback method to return an {@link android.os.IBinder} that
590 through {@link android.app.Service#onStartCommand onStartCommand()}).</p>
595 return from the {@link android.app.Service#onBind
632 <h2 id="Foreground">Running a Service in the Foreground</h2>
646 android.app.Service#startForeground startForeground()}. This method takes two parameters: an integer
661 android.app.Service#startForeground startForeground()} must not be 0.</p>
665 android.app.Service#stopForeground stopForeground()}. This method takes a boolean, indicating
676 <h2 id="Lifecycle">Managing the Lifecycle of a Service</h2>
690 android.app.Service#stopSelf() stopSelf()}. Another component can also stop the
710 android.content.Context#stopService stopService()} or {@link android.app.Service#stopSelf
721 public class ExampleService extends Service {
727 public void {@link android.app.Service#onCreate onCreate}() {
731 …public int {@link android.app.Service#onStartCommand onStartCommand}(Intent intent, int flags, int…
736 public IBinder {@link android.app.Service#onBind onBind}(Intent intent) {
741 public boolean {@link android.app.Service#onUnbind onUnbind}(Intent intent) {
746 public void {@link android.app.Service#onRebind onRebind}(Intent intent) {
751 public void {@link android.app.Service#onDestroy onDestroy}() {
770 android.app.Service#onCreate onCreate()} is called and the time {@link
771 android.app.Service#onDestroy} returns. Like an activity, a service does its initial setup in
772 {@link android.app.Service#onCreate onCreate()} and releases all remaining resources in {@link
773 android.app.Service#onDestroy onDestroy()}. For example, a
775 android.app.Service#onCreate onCreate()}, then stop the thread in {@link
776 android.app.Service#onDestroy onDestroy()}.
778 <p>The {@link android.app.Service#onCreate onCreate()} and {@link android.app.Service#onDestroy
784 android.app.Service#onStartCommand onStartCommand()} or {@link android.app.Service#onBind onBind()}.
789 ends (the service is still active even after {@link android.app.Service#onStartCommand
791 android.app.Service#onUnbind onUnbind()} returns.</p>
796 either {@link android.app.Service#stopSelf stopSelf()} or {@link
800 android.app.Service#onDestroy onDestroy()} is the only callback received.</p>
806 So, a service that was initially started with {@link android.app.Service#onStartCommand
808 can still receive a call to {@link android.app.Service#onBind onBind()} (when a client calls
813 which includes more information about the {@link android.app.Service#onRebind onRebind()}
816 a Bound Service</a>.</p>