| CLASS info |
| public class LocationRequest implements IMessageEntity |
| 定位的请求信息类。 |
| Return type | Method name | Description |
| Creator<LocationRequest> | CREATOR | LocationRequest构建器 |
| Type | Name | Desc |
| int | PRIORITY_HIGH_ACCURACY | 用于请求最准确的位置 |
| int | PRIORITY_BALANCED_POWER_ACCURACY | 用于请求“街区”级精度 |
| int | PRIORITY_LOW_POWER | 用于请求“城市”级别的准确性 |
| int | PRIORITY_NO_POWER | 用于在零额外功耗下请求最佳精度 |
| int | PRIORITY_HD_ACCURACY | 用于请求高精度的位置信息,当前仅限于requestLocationUpdatesEx接口使用。 |
| Return type | Method name |
| LocationRequest | create() |
| LocationRequest | setPriority(int priority) |
| LocationRequest | setInterval(long millis) |
| LocationRequest | setNumUpdates(int numUpdates) |
| LocationRequest | setFastestInterval(long millis) |
| boolean | isFastestIntervalExplicitlySet() |
| LocationRequest | setExpirationTime(long millis) |
| LocationRequest | setExpirationDuration(long millis) |
| LocationRequest | setSmallestDisplacement(float smallestDisplacement) |
| LocationRequest | setMaxWaitTime(long millis) |
| LocationRequest | setNeedAddress(boolean needAddress) |
| LocationRequest | setLanguage(String language) |
| LocationRequest | setCountryCode(String countryCode) |
| Constant |
| public static final int PRIORITY_HIGH_ACCURACY |
| 用于请求最准确的位置。 默认值: 100 |
| Constant |
| public static final int PRIORITY_BALANCED_POWER_ACCURACY |
| 用于请求“街区”级精度。 默认值: 102 |
| Constant |
| public static final int PRIORITY_LOW_POWER |
| 用于请求“城市”级别的准确性。 默认值: 104 |
| Constant |
| public static final int PRIORITY_NO_POWER |
| 用于在零额外功耗下请求最佳精度。 默认值: 105 |
| Constant |
| public static final int PRIORITY_HD_ACCURACY |
| 用于请求高精度的位置信息,当前仅限于requestLocationUpdatesEx接口使用。 默认值: 200 |
| Method |
| public LocationRequest create() |
| 创建LocationRequest。 |
| Method |
| public LocationRequest setPriority(int priority) |
| 设置优先级,如果请求GPS位置,则值为100;如请求网络位置,则值为102或104;如不需要主动请求位置,仅需被动接收位置,则值为105。如果请求高精度位置信息,则值为200。 |
Parameters
| Parameter name | Parameter desc |
| priority | 请求的优先级,默认为100。 |
| Method |
| public LocationRequest setInterval(long millis) |
| 请求位置回调的时间间隔。假如值为50000,则位置请求每隔50秒回调一次结果。 |
Parameters
| Parameter name | Parameter desc |
| millis | 回调时间间隔,以毫秒为单位,默认为3600000。 |
| Method |
| public LocationRequest setNumUpdates(int numUpdates) |
| 请求位置的回调次数,假如值为3时,则只回调3次结果给客户端。 |
Parameters
| Parameter name | Parameter desc |
| numUpdates | 位置请求回调次数,默认为Integer.MAX_VALUE。 |
| Method |
| public LocationRequest setFastestInterval(long millis) |
| 请求位置回调的最快时间间隔,取Interval和FastestInterval的较小值。 |
Parameters
| Parameter name | Parameter desc |
| millis | 请求的最快时间间隔,以毫秒为单位,默认为600000。如果有其他应用发起位置请求,满足fastestInterval周期后,同样会上报位置。 |
| Method |
| public boolean isFastestIntervalExplicitlySet() |
| 是否使用最快时间间隔。 |
Return
| Parameter name | Parameter desc |
| boolean | 如果使用最快时间间隔,则返回true;否则返回false。 |
| Method |
| public LocationRequest setExpirationTime(long millis) |
| 请求到期时间,该时间自开机启动算起,开机启动到当前时间可使用SystemClock.elapsedRealtime()获取。假如200秒后位置回调需要停止,则该参数值应为SystemClock.elapsedRealtime() + 200000。 |
Parameters
| Parameter name | Parameter desc |
| millis | 请求到期时间,以毫秒为单位,默认为Long.MAX_VALUE。 |
| Method |
| public LocationRequest setExpirationDuration(long millis) |
| 请求到期时间段,该参数与expirationTime的区别为,该参数不需要考虑开机启动时间。假如200秒后位置回调需要停止,则该参数值应为200000。 |
Parameters
| Parameter name | Parameter desc |
| millis | 请求到期时间,以毫秒为单位,默认为Long.MAX_VALUE。 |
| Method |
| public LocationRequest setSmallestDisplacement(float smallestDisplacement) |
| 位置更新的最小位移。两次回调位置之间的距离满足该参数的值,则进行位置回调。 |
Parameters
| Parameter name | Parameter desc |
| smallestDisplacement | 位置更新的最小位移,以米为单位,默认为0。 |
| Method |
| public LocationRequest setMaxWaitTime(long millis) |
| 设置最长等待时间。 |
Parameters
| Parameter name | Parameter desc |
| millis | 最长等待时间。 |
| Method |
| public LocationRequest setNeedAddress(boolean needAddress) |
| 设置是否需要返回地址信息 |
Parameters
| Parameter name | Parameter desc |
| needAddress | 设置是否需要返回地址信息,默认为false |
| Method |
| public LocationRequest setLanguage(String language) |
| 设置语言 |
Parameters
| Parameter name | Parameter desc |
| language | 设置语言,2字母代码,使用ISO 639-1国际标准,默认为空 |
| Method |
| public LocationRequest setCountryCode(String countryCode) |
| 设置国家 |
Parameters
| Parameter name | Parameter desc |
| countryCode | 设置国家,2字母代码,使用ISO 3166-1国际标准,默认为空 |