智能客服
你问我答,随时在线为你解决问题
Class Info |
|---|
public class LocationRequest implements Parcelable, IMessageEntity 定位的请求信息类,在调用该类的create()方法时会返回一个该类型的实例。 |
- LocationRequest mLocationRequest;
- mLocationRequest = new LocationRequest();
- mLocationRequest.setInterval(5000);
- mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
- val mLocationRequest: LocationRequest
- mLocationRequest = LocationRequest()
- mLocationRequest.interval = 5000
- mLocationRequest.priority = LocationRequest.PRIORITY_HIGH_ACCURACY
Qualifier and Type | Field and Description |
|---|---|
static final Creator<LocationRequest> | LocationRequest构建器。 |
static final int | PRIORITY_BALANCED_POWER_ACCURACY 用于请求“街区”级精度。 |
static final int | 用于请求室外高精度的位置信息,当前仅限于requestLocationUpdatesEx接口使用。 注意
|
static final int | 用于请求最准确的位置。 |
static final int | 用于请求“城市”级别的准确性。 |
static final int | 用于在零额外功耗下请求最佳精度。 |
static final int | 用于请求室内定位,当前仅限于requestLocationUpdatesEx接口使用。 |
static final int | PRIORITY_HIGH_ACCURACY_AND_INDOOR 用于请求室内定位和融合定位,当前仅限于requestLocationUpdatesEx接口使用。 |
Constructor Name |
|---|
| 构建一个LocationRequest实例。 |
Qualifier and Type | Method Name and Description |
|---|---|
LocationRequest | create() 创建LocationRequest。 |
boolean | isFastestIntervalExplicitlySet() 是否使用最快时间间隔。 |
LocationRequest | setCountryCode(String countryCode) 设置国家。 |
LocationRequest | setExpirationDuration(long millis) 请求到期时间段,单位:毫秒。 |
LocationRequest | setExpirationTime(long millis) 请求到期时间,单位:毫秒。 |
LocationRequest | setFastestInterval(long millis) 请求位置回调的最快时间间隔,取Interval和FastestInterval的较小值, 单位:毫秒。如果您确实需要设置fastestInterval,建议设置fastestInterval值远小于Interval,这样才有显著的效果。 |
LocationRequest | setInterval(long millis) 请求位置回调的时间间隔,单位:毫秒。 |
LocationRequest | setLanguage(String language) 设置语言。 |
LocationRequest | setMaxWaitTime(long millis) 设置位置更新的最长等待时间,单位:毫秒。 |
LocationRequest | setNeedAddress(boolean needAddress) 设置是否需要返回地址信息。 |
LocationRequest | setNumUpdates(int numUpdates) 请求位置的回调次数,假如值为3时,则只回调3次结果给客户端。 |
LocationRequest | setPriority(int priority) 设置定位类型。 注意
|
LocationRequest | setSmallestDisplacement(float smallestDisplacement) 位置更新的最小位移,单位:米。 |
Fields |
|---|
public static final Creator<LocationRequest> CREATOR LocationRequest构建器。用以反序列化定位的请求信息类时使用。 |
Fields |
|---|
public static final int PRIORITY_BALANCED_POWER_ACCURACY 用于请求“街区”级精度。 PRIORITY_BALANCED_POWER_ACCURACY:102,其余常量值请参阅:Constant-values。 |
Fields |
|---|
public static final int PRIORITY_HD_ACCURACY 用于请求室外高精度的位置信息,当前仅限于requestLocationUpdatesEx接口使用。 PRIORITY_HD_ACCURACY:200,其余常量值请参阅:Constant-values。 |
Fields |
|---|
public static final int PRIORITY_HIGH_ACCURACY 用于请求最准确的位置。 PRIORITY_HIGH_ACCURACY:100,其余常量值请参阅:Constant-values。 |
Fields |
|---|
public static final int PRIORITY_LOW_POWER 用于请求“城市”级别的准确性。 PRIORITY_LOW_POWER:104,其余常量值请参阅:Constant-values。 |
Fields |
|---|
public static final int PRIORITY_NO_POWER 用于在零额外功耗下请求最佳精度。 PRIORITY_NO_POWER:105,其余常量值请参阅:Constant-values。 |
Fields |
|---|
public static final int PRIORITY_INDOOR 用于请求室内定位。 PRIORITY_INDOOR:300,其余常量值请参阅:Constant-values。 |
Fields |
|---|
public static final int PRIORITY_HIGH_ACCURACY_AND_INDOOR 用于请求室内定位和融合定位。 PRIORITY_HIGH_ACCURACY_AND_INDOOR:400,室内定位的相关约束条件,请参考室内定位开发,其余常量值请参阅:Constant-values。 |
Constructor |
|---|
public LocationRequest() 构建一个LocationRequest实例。 |
Method |
|---|
public static LocationRequest create() 创建LocationRequest。 |
Returns
Type | Description |
|---|---|
LocationRequest | 定位的请求信息类。 |
Method |
|---|
public boolean isFastestIntervalExplicitlySet() 是否使用最快时间间隔。 |
Returns
Type | Description |
|---|---|
boolean | 如果使用最快时间间隔,则返回true,否则返回false。 |
Method |
|---|
public LocationRequest setCountryCode(String countryCode) 设置国家。 |
Parameters
Name | Description |
|---|---|
countryCode | 设置国家,格式为两个字母,使用ISO 3166-1国际标准,默认为空。当前仅支持EN和CN。 |
Returns
Type | Description |
|---|---|
LocationRequest | 定位的请求信息类。 |
Method |
|---|
public LocationRequest setExpirationDuration(long millis) 请求到期时间段,该参数与expirationTime的区别为,该参数不需要考虑开机启动时间。假如200秒后位置回调需要停止,则该参数值应为200000。 |
Parameters
Name | Description |
|---|---|
millis | 请求到期时间,单位:毫秒,默认为Long.MAX_VALUE。 |
Returns
Type | Description |
|---|---|
LocationRequest | 定位的请求信息类。 |
Method |
|---|
public LocationRequest setExpirationTime(long millis) 请求到期时间,该时间自开机启动算起,开机启动到当前时间可使用SystemClock.elapsedRealtime()获取。假如200秒后位置回调需要停止,则该参数值应为SystemClock.elapsedRealtime() + 200000。 |
Parameters
Name | Description |
|---|---|
millis | 请求到期时间,单位:毫秒,默认为Long.MAX_VALUE。 |
Returns
Type | Description |
|---|---|
LocationRequest | 定位的请求信息类。 |
Method |
|---|
public LocationRequest setFastestInterval(long millis) 请求位置回调的最快时间间隔,默认值为Interval的1/6。 |
Parameters
Name | Description |
|---|---|
millis | 请求的最快时间间隔,单位:毫秒,默认为600000。如果有其他应用发起位置请求,满足fastestInterval周期后,同样会上报位置。 |
Returns
Type | Description |
|---|---|
LocationRequest | 定位的请求信息类。 |
Throws
Name | Description |
|---|---|
IllegalArgumentException | 参数不可用。传入的millis小于0,请确保它的正确性。 |
Method |
|---|
public LocationRequest setInterval(long millis) 请求位置回调的时间间隔。假如值为50000,则位置请求每隔50秒回调一次结果。 |
Parameters
Name | Description |
|---|---|
millis | 回调时间间隔,单位:毫秒,默认值为3600000。 |
Returns
Type | Description |
|---|---|
LocationRequest | 定位的请求信息类。 |
Throws
Name | Description |
|---|---|
IllegalArgumentException | 参数不可用。传入的millis小于0,请确保它的正确性。 |
Method |
|---|
public LocationRequest setLanguage(String language) 设置语言。 |
Parameters
Name | Description |
|---|---|
language | 设置语言,格式为两个字母(例如:en表示英文)。使用ISO 639-1国际标准,默认为空。当前仅支持en和zh。 |
Returns
Type | Description |
|---|---|
LocationRequest | 定位的请求信息类。 |
Method |
|---|
public LocationRequest setMaxWaitTime(long millis) 设置位置更新的最长等待时间,单位:毫秒。 生效时,位置更新会以maxWaitTime的时间为更新周期,在满足位置更新时间后,会将周期内的位置一次性返回给应用。 说明
|
Parameters
Name | Description |
|---|---|
millis | 最长等待时间,单位:毫秒。 |
Returns
Type | Description |
|---|---|
LocationRequest | 定位的请求信息类。 |
Method |
|---|
public LocationRequest setNeedAddress(boolean needAddress) 设置是否需要返回地址信息。 |
Parameters
Name | Description |
|---|---|
needAddress | 设置是否需要返回地址信息,默认为false。 |
Returns
Type | Description |
|---|---|
LocationRequest | 定位的请求信息类。 |
Method |
|---|
public LocationRequest setNumUpdates(int numUpdates) 请求位置的回调次数,假如值为3时,则只回调3次结果给客户端。 |
Parameters
Name | Description |
|---|---|
numUpdates | 位置请求回调次数,默认为Integer.MAX_VALUE。 |
Returns
Type | Description |
|---|---|
LocationRequest | 定位的请求信息类。 |
Throws
Name | Description |
|---|---|
IllegalArgumentException | 参数不可用。传入的numUpdates小于或者等于0,请确保它的正确性。 |
Method |
|---|
public LocationRequest setPriority(int priority) 设置定位类型,如果请求GNSS位置,则值为100;如请求网络位置,则值为102或104;如不需要主动请求位置,仅需被动接收位置,则值为105。如果请求室外高精度位置信息,则值为200;如果请求室内的位置信息,则值为300。 |
Parameters
Name | Description |
|---|---|
priority | 请求的定位类型,默认值为102。 |
Returns
Type | Description |
|---|---|
LocationRequest | 定位的请求信息类。 |
Throws
Name | Description |
|---|---|
IllegalArgumentException | 参数错误。请确保传入的priority是LocationRequest请求定义的定位类型之一。 |
Method |
|---|
public LocationRequest setSmallestDisplacement(float smallestDisplacement) 位置更新的最小位移。两次回调位置之间的距离满足该参数的值,则进行位置回调。 |
Parameters
Name | Description |
|---|---|
smallestDisplacement | 位置更新的最小位移,单位:米,默认值为0。 |
Returns
Type | Description |
|---|---|
LocationRequest | 定位的请求信息类。 |
Throws
Name | Description |
|---|---|
IllegalArgumentException | 参数不可用。传入的smallestDisplacement小于0.0,请确保参数的可用性。 |