• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.content;
18 
19 import android.os.IBinder;
20 
21 /**
22  * Interface for monitoring the state of an application service.  See
23  * {@link android.app.Service} and
24  * {@link Context#bindService Context.bindService()} for more information.
25  * <p>Like many callbacks from the system, the methods on this class are called
26  * from the main thread of your process.
27  */
28 public interface ServiceConnection {
29     /**
30      * Called when a connection to the Service has been established, with
31      * the {@link android.os.IBinder} of the communication channel to the
32      * Service.
33      *
34      * @param name The concrete component name of the service that has
35      * been connected.
36      *
37      * @param service The IBinder of the Service's communication channel,
38      * which you can now make calls on.
39      */
onServiceConnected(ComponentName name, IBinder service)40     public void onServiceConnected(ComponentName name, IBinder service);
41 
42     /**
43      * Called when a connection to the Service has been lost.  This typically
44      * happens when the process hosting the service has crashed or been killed.
45      * This does <em>not</em> remove the ServiceConnection itself -- this
46      * binding to the service will remain active, and you will receive a call
47      * to {@link #onServiceConnected} when the Service is next running.
48      *
49      * @param name The concrete component name of the service whose
50      * connection has been lost.
51      */
onServiceDisconnected(ComponentName name)52     public void onServiceDisconnected(ComponentName name);
53 }
54