android location包---LocationManager简介

来源:互联网 发布:手机淘宝怎么激活 编辑:程序博客网 时间:2024/06/15 06:53

LocationManager简介

                             LocationManager提供连接本地位置服务,这些本地位置允许应用程序获取定期更新设备的地理位置,或当设备进入一个特定地理位置接近,触发一个特定意图

                             LocationManager类不能实例化,但可以通过 Context.getSystemService(Context.LOCATION_SERVICE).方法。

相关属性参数:

GPS_PROVIDER:GPS位置提供者名称。

NETWORK_PROVIDER网络位置提供者名称

 

相关方法介绍:

addGpsStatusListener(GpsStatus.Listener listener):添加GPS状态监听器。

addNmeaListener(GpsStatus.NmeaListener listener):添加监听器名称。

addProximityAlert(double latitude, double longitude, float radius, long expiration, PendingIntent intent):设置特定的位置提示,给定特定位置的经纬度坐标和半径。

addTestProvider(String name, boolean requiresNetwork, boolean requiresSatellite, boolean requiresCell, boolean hasMonetaryCost, boolean supportsAltitude, boolean supportsSpeed, boolean supportsBearing, int powerRequirement, int accuracy):创建模拟位置提供者,并添加到活动的位置提供者中。

clearTestProviderEnabled(String provider):在位置提供者中移除虚拟位置提供者。

clearTestProviderLocation(String provider):移除一些位置服务提供者提供的虚假位置。

clearTestProviderStatus(String provider):移除一些位置服者提供者提供的虚拟状态。

getAllProviders():返回List包含名称的位置服务提供者。

getBestProvider(Criteria criteria, boolean enabledOnly):返回最符合标准的位置服务提供者的名称。

getGpsStatus(GpsStatus status):检测当前GPS设备的状态。

getLastKnownLocation(String provider):指定位置服务提供者名称返回该位置服务提供位置信息。

getProvider(String name):指定服务提供者名称返回实例。

getProviders(boolean enabledOnly):返回一个列表位置提供者名称。

getProviders(Criteria criteria, boolean enabledOnly):返回满足指定条件一个列表的位置提供者。

isProviderEnabled(String provider):返回指定位置提供者是否启动。

removeGpsStatusListener(GpsStatus.Listener listener):移除GPS状态监听器。

removeNmeaListener(GpsStatus.NmeaListener listener):移除指定名称的监听器。

removeProximityAlert(PendingIntent intent):移除接近警报PendingIntent.

removeTestProvider(String provider):移除指定名称虚假位置提供者。

removeUpdates(PendingIntent intent):移除所有指定的PendingIntent位置更改。

removeUpdates(LocationListener listener):移除所有指定LocationListener的位置更改。

requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener):注册位置更新通过指定的位置服务提供者和PendingIntent。

requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener, Looper looper):注册位置更新通过指定的位置服务提供者和和指定线程的回调方法。

requestLocationUpdates(String provider, long minTime, float minDistance, PendingIntent intent):注册位置更新通过指定的位置服务和PendingIntent。

sendExtraCommand(String provider, String command, Bundle extras):位置服务提供提供而外的命令。

setTestProviderEnabled(String provider, boolean enabled):设置模拟位置提供者地值。

setTestProviderLocation(String provider, Location loc):设置模拟位置提供者的名称。

setTestProviderStatus(String provider, int status, Bundle extras, long updateTime):设置虚拟位置提供者提供的值。

原创粉丝点击