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.annotation.NonNull; 20 import android.os.Bundle; 21 22 /** 23 * Used for receiving notifications from the LocationManager when 24 * the location has changed. These methods are called if the 25 * LocationListener has been registered with the location manager service 26 * using the {@link LocationManager#requestLocationUpdates(String, long, float, LocationListener)} 27 * method. 28 * 29 * <div class="special reference"> 30 * <h3>Developer Guides</h3> 31 * <p>For more information about identifying user location, read the 32 * <a href="{@docRoot}guide/topics/location/obtaining-user-location.html">Obtaining User 33 * Location</a> developer guide.</p> 34 * </div> 35 */ 36 public interface LocationListener { 37 38 /** 39 * Called when the location has changed. 40 * 41 * @param location the updated location 42 */ onLocationChanged(@onNull Location location)43 void onLocationChanged(@NonNull Location location); 44 45 /** 46 * This callback will never be invoked on Android Q and above, and providers can be considered 47 * as always in the {@link LocationProvider#AVAILABLE} state. 48 * 49 * @deprecated This callback will never be invoked on Android Q and above. 50 */ 51 @Deprecated onStatusChanged(String provider, int status, Bundle extras)52 default void onStatusChanged(String provider, int status, Bundle extras) {} 53 54 /** 55 * Called when the provider is enabled by the user. 56 * 57 * @param provider the name of the location provider that has become enabled 58 */ onProviderEnabled(@onNull String provider)59 default void onProviderEnabled(@NonNull String provider) {} 60 61 /** 62 * Called when the provider is disabled by the user. If requestLocationUpdates 63 * is called on an already disabled provider, this method is called 64 * immediately. 65 * 66 * @param provider the name of the location provider that has become disabled 67 */ onProviderDisabled(@onNull String provider)68 default void onProviderDisabled(@NonNull String provider) {} 69 } 70