LocationListener.java revision 54b6cfa9a9e5b861a9930af873580d6dc20f773c
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 17package android.location; 18 19import 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 */ 28public interface LocationListener { 29 30 /** 31 * Called when the location has changed. 32 * 33 * <p> There are no restrictions on the use of the supplied Location object. 34 * 35 * @param location The new location, as a Location object. 36 */ 37 void onLocationChanged(Location location); 38 39 /** 40 * Called when the provider status changes. This method is called when 41 * a provider is unable to fetch a location or if the provider has recently 42 * become available after a period of unavailability. 43 * 44 * @param provider the name of the location provider associated with this 45 * update. 46 * @param status {@link LocationProvider#OUT_OF_SERVICE} if the 47 * provider is out of service, and this is not expected to change in the 48 * near future; {@link LocationProvider#TEMPORARILY_UNAVAILABLE} if 49 * the provider is temporarily unavailable but is expected to be available 50 * shortly; and {@link LocationProvider#AVAILABLE} if the 51 * provider is currently available. 52 * @param extras an optional Bundle which will contain provider specific 53 * status variables. 54 * 55 * <p> A number of common key/value pairs for the extras Bundle are listed 56 * below. Providers that use any of the keys on this list must 57 * provide the corresponding value as described below. 58 * 59 * <ul> 60 * <li> satellites - the number of satellites used to derive the fix 61 * </ul> 62 */ 63 void onStatusChanged(String provider, int status, Bundle extras); 64 65 /** 66 * Called when the provider is enabled by the user. 67 * 68 * @param provider the name of the location provider associated with this 69 * update. 70 */ 71 void onProviderEnabled(String provider); 72 73 /** 74 * Called when the provider is disabled by the user. If requestLocationUpdates 75 * is called on an already disabled provider, this method is called 76 * immediately. 77 * 78 * @param provider the name of the location provider associated with this 79 * update. 80 */ 81 void onProviderDisabled(String provider); 82} 83