Sequenceablepublic class RequestParam extends Object implements Sequenceable
SequenceableSystemCapability.Location#LOCATIONSequenceable.Producer<T>| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
PRIORITY_ACCURACY |
Indicates the priority over location accuracy.
|
static int |
PRIORITY_FAST_FIRST_FIX |
Indicates the priority over fast location.
|
static int |
PRIORITY_LOW_POWER |
Indicates the priority over power efficiency.
|
static int |
PRIORITY_UNSET |
Indicates the default location priority policy used when no location priority policy is set.
|
static int |
SCENE_CAR_HAILING |
Indicates the scenario of obtaining the current location of a user who is hailing a taxi.
|
static int |
SCENE_DAILY_LIFE_SERVICE |
Indicates the scenario of obtaining the approximate user location for recommendations and push notifications,
for example, when the user is browsing news, shopping online, and ordering food.
|
static int |
SCENE_NAVIGATION |
Indicates the scenario of user navigation, for example, map applications' navigation for driving or walking.
|
static int |
SCENE_NO_POWER |
Indicates the scenario in which your application does not proactively start the location service
for a higher battery efficiency.
|
static int |
SCENE_TRAJECTORY_TRACKING |
Indicates the scenario of recording user trajectories,
for example, the track recording function of sports applications.
|
static int |
SCENE_UNSET |
Indicates the default location type used when no location scenario type is set.
|
| 构造器 | 说明 |
|---|---|
RequestParam(int scenario) |
Creates a
RequestParam object for the location request based on the location scenario type. |
RequestParam(int priority,
int timeInterval,
int distanceInterval) |
Creates a
RequestParam object for the location request based on parameters such as the
location priority policy. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
int |
getDistanceInterval() |
Obtains the minimum moving distance in the
RequestParam object. |
float |
getMaxAccuracy() |
Obtain the location accuracy threshold in the
RequestParam object. |
int |
getPriorityLevel() |
Obtains the location priority policy in the
RequestParam object. |
int |
getScenario() |
Obtains the location priority policy in the
RequestParam object. |
int |
getTimeInterval() |
Obtains the minimum time interval (in seconds) in the
RequestParam object. |
boolean |
marshalling(Parcel out) |
Marshalls a
RequestParam object into a parcel. |
void |
setDistanceInterval(int value) |
Sets the minimum moving distance (in meters) for reporting the location result.
|
void |
setMaxAccuracy(float value) |
Sets the location accuracy threshold (in meters) for reporting the location result.
|
void |
setPriorityLevel(int value) |
Sets the location priority policy for initiating the location services if the location scenario types
provided by the system fail to meet your location requirements.
|
void |
setScenario(int scenario) |
Sets the location scenario type.
|
void |
setTimeInterval(int value) |
Sets the minimum time interval (in seconds) for reporting the location result.
|
String |
toString() |
Returns a string representation of this
RequestParam object. |
boolean |
unmarshalling(Parcel in) |
Unmarshalls a
RequestParam object and updates its data. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waithasFileDescriptorpublic static final int PRIORITY_ACCURACY
This priority relies on the satellite system to locate the current location of the user device. It can provide a better location result in open areas.
To use this priority, your application needs to apply for
the ohos.permission.LOCATION permission and obtain user authorization.
public static final int PRIORITY_FAST_FIRST_FIX
If this priority is selected, the system reports the real-time location result immediately upon receiving the location request.
To use this priority, your application needs to apply for
the ohos.permission.LOCATION permission and obtain user authorization.
public static final int PRIORITY_LOW_POWER
This priority relies on the Wi-Fi hotspots or cell IDs to estimate the current location of the user device. It consumes less power than the location accuracy priority but requires that the user device is able to access the Internet.
To use this priority, your application needs to apply for
the ohos.permission.LOCATION permission and obtain user authorization.
public static final int PRIORITY_UNSET
public static final int SCENE_CAR_HAILING
In this scenario, the system reports the location result at a minimum interval of 1s by default.
To use this scenario, your application needs to apply for
the ohos.permission.LOCATION permission and obtain user authorization.
public static final int SCENE_DAILY_LIFE_SERVICE
In this scenario, the system reports the location result at a minimum interval of 1s by default.
To use this scenario, your application needs to apply for
the ohos.permission.LOCATION permission and obtain user authorization.
public static final int SCENE_NAVIGATION
In this scenario, the system reports the location result at a minimum interval of 1s by default.
To use this scenario, your application must apply for the ohos.permission.LOCATION permission
and obtain user authorization.
public static final int SCENE_NO_POWER
When responding to another application requesting the same location service, the system marks a copy of location result to your application. In this way, your application will not consume extra power for obtaining the user location.
In this scenario, the system reports the location result at a minimum interval of 1s by default.
To use this scenario, your application needs to apply for
the ohos.permission.LOCATION permission and obtain user authorization.
public static final int SCENE_TRAJECTORY_TRACKING
In this scenario, the system reports the location result at a minimum interval of 1s by default.
To use this scenario, your application must apply for the ohos.permission.LOCATION permission
and obtain user authorization.
public static final int SCENE_UNSET
public RequestParam(int scenario)
throws IllegalArgumentException
RequestParam object for the location request based on the location scenario type.
You are advised to use the location scenario types defined by the system. Unless otherwise required,
you do not need to set other parameters for this data class. For details about the location scenario types,
go to the respective link:
SCENE_NAVIGATION
SCENE_TRAJECTORY_TRACKING
SCENE_CAR_HAILING
SCENE_DAILY_LIFE_SERVICE
SCENE_NO_POWER
The location priority policy configured by will become invalid after
the RequestParam object is initialized using this method.
However, you can still choose to configure parameters specific to reporting of location results,
such as the time interval, distance between locations, and location accuracy threshold. For details,
see setTimeInterval(int), setDistanceInterval(int), and setMaxAccuracy(float).
scenario - Specifies the location scenario type.IllegalArgumentException - Throws this exception if the specified location scenario type
has not been defined in RequestParam.public RequestParam(int priority,
int timeInterval,
int distanceInterval)
throws IllegalArgumentException
RequestParam object for the location request based on parameters such as the
location priority policy.
You need to set the location priority policy, and the time interval and moving distance for reporting the location result.
For details about the location priority policy, go to the respective link:
PRIORITY_ACCURACY
PRIORITY_LOW_POWER
PRIORITY_FAST_FIRST_FIX
If you need to set the location accuracy threshold, refer to setMaxAccuracy(float).
The default value is 0.0,which indicates that the location accuracy is not applied
when reporting the location result.
priority - Specifies the location priority policy.timeInterval - Specifies the minimum time interval (in seconds) for reporting the location result.
A valid value is greater than or equal to 1. The default value 0 will be used
if the specified value is smaller than 1.distanceInterval - Specifies the minimum moving distance (in meters) for reporting the location result.
A valid value is greater than or equal to 1. The default value 0 will be used
if the specified value is smaller than 1.IllegalArgumentException - Throws this exception if the specified location priority policy
has not been defined in RequestParam.public int getScenario()
RequestParam object.
For details about the location scenario types, go to the respective link:
SCENE_NAVIGATION
SCENE_TRAJECTORY_TRACKING
SCENE_CAR_HAILING
SCENE_DAILY_LIFE_SERVICE
SCENE_NO_POWER
SCENE_UNSET will be returned.public void setScenario(int scenario)
throws IllegalArgumentException
For details about the location scenario types, go to the respective link:
SCENE_NAVIGATION
SCENE_TRAJECTORY_TRACKING
SCENE_CAR_HAILING
SCENE_DAILY_LIFE_SERVICE
SCENE_NO_POWER
The location priority policy configured by will become invalid after the location scenario type is set using this method.
However, you can still choose to configure parameters specific to reporting of location results,
such as the time interval, moving distance, and location accuracy threshold. For details,
see setTimeInterval(int), setDistanceInterval(int), and setMaxAccuracy(float).
scenario - Specifies the location scenario type.IllegalArgumentException - Throws this exception if the specified location scenario type
has not been defined in RequestParam.public int getPriorityLevel()
RequestParam object.
For details about the location priority policy, go to the respective link:
PRIORITY_ACCURACY
PRIORITY_LOW_POWER
PRIORITY_FAST_FIRST_FIX
PRIORITY_UNSET will be returned.public void setPriorityLevel(int value)
throws IllegalArgumentException
For details about the location priority policy for different scenarios, go to the respective link:
PRIORITY_ACCURACY
PRIORITY_LOW_POWER
PRIORITY_FAST_FIRST_FIX
value - Specifies the location priority policy.IllegalArgumentException - Throws this exception if the specified location priority policy
has not been defined in RequestParam.public int getTimeInterval()
RequestParam object.0, which indicates that the system reports the location
result at an interval of at least 1s.public void setTimeInterval(int value)
The system ensures that the time interval between two consecutive location results is greater than or equal to the specified value.
The default value is 0, which indicates that the system reports the location
result to the application immediately after successful location.
value - Specifies the minimum time interval (in meters) for reporting the location result.
A valid value is greater than or equal to 1. The default value 0 will be used
if the specified value is smaller than 1.public int getDistanceInterval()
RequestParam object.
If the moving distance between the current location and the previously reported location exceeds the specified value, the location result is reported to the application.
0, which indicates that the minimum moving distance is not applied
when reporting the location result.public void setDistanceInterval(int value)
If the moving distance between the current location and the previously reported location exceeds the specified value, the location result is reported to the application.
The default value of is 0, which indicates that the minimum moving distance is not applied
when reporting the location result.
value - Specifies the minimum moving distance (in meters) for reporting the location result.
A valid value is greater than or equal to 1. The default value 0 will be used
if the specified value is smaller than 1.public float getMaxAccuracy()
RequestParam object.0,
which indicates that the location accuracy threshold is not applied when reporting the location result.public void setMaxAccuracy(float value)
If the location accuracy of the system does not exceed the specified value, the location result is reported to the application.
The default value is 0, which indicates that the location accuracy
threshold is not applied when reporting the location result.
value - Specifies the location accuracy threshold. A valid value is greater than or equal to 1.
The default value 0 will be used if the specified value is smaller than 1.public boolean unmarshalling(Parcel in)
RequestParam object and updates its data.
Unmarshalling of RequestParam objects is implemented using Sequenceable.
unmarshalling 在接口中 Sequenceablein - Specifies the Parcel object for unmarshalling a GeoAddress object.
The value must not be null.true if unmarshaling is successful; returns false otherwise.Parcel,
Sequenceablepublic boolean marshalling(Parcel out)
RequestParam object into a parcel.
Marshalling of RequestParam objects is implemented using Sequenceable.
marshalling 在接口中 Sequenceableout - Specifies the Parcel object for marshalling a RequestParam object.
The value cannot be null.true if marshaling is successful; returns false otherwise.Parcel,
Sequenceable