Most visited

Recently visited

Added in API level 1

LocationListener

public interface LocationListener

android.location.LocationListener


用于在位置发生变化时从LocationManager接收通知。 如果LocationListener已使用requestLocationUpdates(String, long, float, LocationListener)方法向位置管理器服务注册,则会调用这些方法。

Developer Guides

有关识别用户位置的更多信息,请阅读 Obtaining User Location开发人员指南。

Summary

Public methods

abstract void onLocationChanged(Location location)

当位置发生变化时调用。

abstract void onProviderDisabled(String provider)

当提供者被用户禁用时调用。

abstract void onProviderEnabled(String provider)

当提供者被用户启用时调用。

abstract void onStatusChanged(String provider, int status, Bundle extras)

当提供者状态改变时调用。

Public methods

onLocationChanged

Added in API level 1
void onLocationChanged (Location location)

当位置发生变化时调用。

使用提供的位置对象没有限制。

Parameters
location Location: The new location, as a Location object.

onProviderDisabled

Added in API level 1
void onProviderDisabled (String provider)

当提供者被用户禁用时调用。 如果在已禁用的提供程序上调用requestLocationUpdates,则立即调用此方法。

Parameters
provider String: the name of the location provider associated with this update.

onProviderEnabled

Added in API level 1
void onProviderEnabled (String provider)

当提供者被用户启用时调用。

Parameters
provider String: the name of the location provider associated with this update.

onStatusChanged

Added in API level 1
void onStatusChanged (String provider, 
                int status, 
                Bundle extras)

当提供者状态改变时调用。 当提供者无法获取位置或提供者最近在不可用时段后变为可用时,将调用此方法。

Parameters
provider String: the name of the location provider associated with this update.
status int: OUT_OF_SERVICE if the provider is out of service, and this is not expected to change in the near future; TEMPORARILY_UNAVAILABLE if the provider is temporarily unavailable but is expected to be available shortly; and AVAILABLE if the provider is currently available.
extras Bundle: an optional Bundle which will contain provider specific status variables.

下面列出了附加软件包的许多常用键/值对。 使用此列表中的任何密钥的提供商必须按照以下说明提供相应的值。

  • satellites - the number of satellites used to derive the fix

Hooray!