1 /*
2  * Copyright (C) 2008 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.location;
18 
19 import android.os.Bundle;
20 
21 /**
22  * Used for receiving notifications from the LocationManager when
23  * the location has changed. These methods are called if the
24  * LocationListener has been registered with the location manager service
25  * using the {@link LocationManager#requestLocationUpdates(String, long, float, LocationListener)}
26  * method.
27  *
28  * <div class="special reference">
29  * <h3>Developer Guides</h3>
30  * <p>For more information about identifying user location, read the
31  * <a href="{@docRoot}guide/topics/location/obtaining-user-location.html">Obtaining User
32  * Location</a> developer guide.</p>
33  * </div>
34  */
35 public interface LocationListener {
36 
37     /**
38      * Called when the location has changed.
39      *
40      * <p> There are no restrictions on the use of the supplied Location object.
41      *
42      * @param location The new location, as a Location object.
43      */
onLocationChanged(Location location)44     void onLocationChanged(Location location);
45 
46     /**
47      * Called when the provider status changes. This method is called when
48      * a provider is unable to fetch a location or if the provider has recently
49      * become available after a period of unavailability.
50      *
51      * @param provider the name of the location provider associated with this
52      * update.
53      * @param status {@link LocationProvider#OUT_OF_SERVICE} if the
54      * provider is out of service, and this is not expected to change in the
55      * near future; {@link LocationProvider#TEMPORARILY_UNAVAILABLE} if
56      * the provider is temporarily unavailable but is expected to be available
57      * shortly; and {@link LocationProvider#AVAILABLE} if the
58      * provider is currently available.
59      * @param extras an optional Bundle which will contain provider specific
60      * status variables.
61      *
62      * <p> A number of common key/value pairs for the extras Bundle are listed
63      * below. Providers that use any of the keys on this list must
64      * provide the corresponding value as described below.
65      *
66      * <ul>
67      * <li> satellites - the number of satellites used to derive the fix
68      * </ul>
69      */
onStatusChanged(String provider, int status, Bundle extras)70     void onStatusChanged(String provider, int status, Bundle extras);
71 
72     /**
73      * Called when the provider is enabled by the user.
74      *
75      * @param provider the name of the location provider associated with this
76      * update.
77      */
onProviderEnabled(String provider)78     void onProviderEnabled(String provider);
79 
80     /**
81      * Called when the provider is disabled by the user. If requestLocationUpdates
82      * is called on an already disabled provider, this method is called
83      * immediately.
84      *
85      * @param provider the name of the location provider associated with this
86      * update.
87      */
onProviderDisabled(String provider)88     void onProviderDisabled(String provider);
89 }
90