未验证 提交 96894d41 编写于 作者: O openharmony_ci 提交者: Gitee

!2843 2494 处理完成:修改格式错误问题

Merge pull request !2843 from ester.zhou/TR-2494
......@@ -14,42 +14,42 @@ The following table describes APIs available for obtaining device location infor
**Table1** APIs for obtaining device location information
| API | Description |
| API | Description |
| -------- | -------- |
| on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>) : void | Registers a listener for location changes with a location request initiated. |
| off(type: 'locationChange', callback?: Callback<Location>) : void | Unregisters the listener for location changes with the corresponding location request deleted. |
| on(type: 'locationServiceState', callback: Callback<boolean>) : void | Registers a listener for location service status change events. |
| off(type: 'locationServiceState', callback: Callback<boolean>) : void | Unregisters the listener for location service status change events. |
| on(type: 'cachedGnssLocationsReporting', request: CachedGnssLoactionsRequest, callback: Callback<Array<Location>>) : void; | Registers a listener for cached GNSS location reports. |
| off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>) : void; | Unregisters the listener for cached GNSS location reports. |
| on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : void; | Registers a listener for satellite status change events. |
| off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : void; | Unregisters the listener for satellite status change events. |
| on(type: 'nmeaMessageChange', callback: Callback<string>) : void; | Registers a listener for GNSS NMEA message change events. |
| off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; | Unregisters the listener for GNSS NMEA message change events. |
| on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Registers a listener for status change events of the specified geofence. |
| off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Unregisters the listener for status change events of the specified geofence. |
| getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>) : void | Obtains the current location. This function uses an asynchronous callback to return the result. |
| getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> | Obtains the current location. This function uses a promise to return the result. |
| getLastLocation(callback: AsyncCallback<Location>) : void | Obtains the previous location. This function uses an asynchronous callback to return the result. |
| getLastLocation() : Promise<Location> | Obtains the previous location. This function uses a promise to return the result. |
| isLocationEnabled(callback: AsyncCallback<boolean>) : void | Checks whether the location service is enabled. This function uses an asynchronous callback to return the result. |
| isLocationEnabled() : Promise<boolean> | Checks whether the location service is enabled. This function uses a promise to return the result. |
| requestEnableLocation(callback: AsyncCallback<boolean>) : void | Requests to enable the location service. This function uses an asynchronous callback to return the result. |
| requestEnableLocation() : Promise<boolean> | Requests to enable the location service. This function uses a promise to return the result. |
| enableLocation(callback: AsyncCallback<boolean>) : void | Enables the location service. This function uses an asynchronous callback to return the result. |
| enableLocation() : Promise<boolean> | Enables the location service. This function uses a promise to return the result. |
| disableLocation(callback: AsyncCallback<boolean>) : void | Disables the location service. This function uses an asynchronous callback to return the result. |
| disableLocation() : Promise<boolean> | Disables the location service. This function uses a promise to return the result. |
| getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; | Obtains the number of cached GNSS locations. This function uses an asynchronous callback to return the result. |
| getCachedGnssLocationsSize() : Promise<number>; | Obtains the number of cached GNSS locations. This function uses a promise to return the result. |
| flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses an asynchronous callback to return the result. |
| flushCachedGnssLocations() : Promise<boolean>; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses a promise to return the result. |
| sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : void; | Sends extended commands to the location subsystem. This function uses an asynchronous callback to return the result. |
| sendCommand(command: LocationCommand) : Promise<boolean>; | Sends extended commands to the location subsystem. This function uses a promise to return the result. |
| isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback<boolean>) : void; | Checks whether a user agrees with the privacy statement of the location service. This function uses an asynchronous callback to return the result. |
| isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean>; | Checks whether a user agrees with the privacy statement of the location service. This function uses a promise to return the result. |
| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean, callback: AsyncCallback<boolean>) : void; | Sets the user confirmation status for the privacy statement of the location service. This function uses an asynchronous callback to return the result. |
| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise<boolean>; | Sets the user confirmation status for the privacy statement of the location service. This function uses a promise to return the result. |
| on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>) : void | Registers a listener for location changes with a location request initiated. |
| off(type: 'locationChange', callback?: Callback<Location>) : void | Unregisters the listener for location changes with the corresponding location request deleted. |
| on(type: 'locationServiceState', callback: Callback<boolean>) : void | Registers a listener for location service status change events. |
| off(type: 'locationServiceState', callback: Callback<boolean>) : void | Unregisters the listener for location service status change events. |
| on(type: 'cachedGnssLocationsReporting', request: CachedGnssLoactionsRequest, callback: Callback<Array<Location>>) : void; | Registers a listener for cached GNSS location reports. |
| off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>) : void; | Unregisters the listener for cached GNSS location reports. |
| on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : void; | Registers a listener for satellite status change events. |
| off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : void; | Unregisters the listener for satellite status change events. |
| on(type: 'nmeaMessageChange', callback: Callback<string>) : void; | Registers a listener for GNSS NMEA message change events. |
| off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; | Unregisters the listener for GNSS NMEA message change events. |
| on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Registers a listener for status change events of the specified geofence. |
| off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Unregisters the listener for status change events of the specified geofence. |
| getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>) : void | Obtains the current location. This function uses an asynchronous callback to return the result. |
| getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> | Obtains the current location. This function uses a promise to return the result. |
| getLastLocation(callback: AsyncCallback<Location>) : void | Obtains the previous location. This function uses an asynchronous callback to return the result. |
| getLastLocation() : Promise<Location> | Obtains the previous location. This function uses a promise to return the result. |
| isLocationEnabled(callback: AsyncCallback<boolean>) : void | Checks whether the location service is enabled. This function uses an asynchronous callback to return the result. |
| isLocationEnabled() : Promise<boolean> | Checks whether the location service is enabled. This function uses a promise to return the result. |
| requestEnableLocation(callback: AsyncCallback<boolean>) : void | Requests to enable the location service. This function uses an asynchronous callback to return the result. |
| requestEnableLocation() : Promise<boolean> | Requests to enable the location service. This function uses a promise to return the result. |
| enableLocation(callback: AsyncCallback<boolean>) : void | Enables the location service. This function uses an asynchronous callback to return the result. |
| enableLocation() : Promise<boolean> | Enables the location service. This function uses a promise to return the result. |
| disableLocation(callback: AsyncCallback<boolean>) : void | Disables the location service. This function uses an asynchronous callback to return the result. |
| disableLocation() : Promise<boolean> | Disables the location service. This function uses a promise to return the result. |
| getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; | Obtains the number of cached GNSS locations. This function uses an asynchronous callback to return the result. |
| getCachedGnssLocationsSize() : Promise<number>; | Obtains the number of cached GNSS locations. This function uses a promise to return the result. |
| flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses an asynchronous callback to return the result. |
| flushCachedGnssLocations() : Promise<boolean>; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses a promise to return the result. |
| sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : void; | Sends extended commands to the location subsystem. This function uses an asynchronous callback to return the result. |
| sendCommand(command: LocationCommand) : Promise<boolean>; | Sends extended commands to the location subsystem. This function uses a promise to return the result. |
| isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback<boolean>) : void; | Checks whether a user agrees with the privacy statement of the location service. This function uses an asynchronous callback to return the result. |
| isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean>; | Checks whether a user agrees with the privacy statement of the location service. This function uses a promise to return the result. |
| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean, callback: AsyncCallback<boolean>) : void; | Sets the user confirmation status for the privacy statement of the location service. This function uses an asynchronous callback to return the result. |
| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise<boolean>; | Sets the user confirmation status for the privacy statement of the location service. This function uses a promise to return the result. |
## How to Develop
......@@ -70,20 +70,18 @@ The following table describes APIs available for obtaining device location infor
```
{
"module": {
"reqPermissions": [{
"reqPermissions": [
"name": "ohos.permission.LOCATION",
"reason": "$string:reason_description",
"usedScene": {
"ability": ["com.myapplication.LocationAbility"],
"when": "inuse"
}, {
...
}
]
}
}
```
For details about the fields, see .
2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities.
......@@ -112,13 +110,13 @@ The following table describes APIs available for obtaining device location infor
**Table2** Common use cases of the location function
| Use Case | Constant | Description |
| Use Case | Constant | Description |
| -------- | -------- | -------- |
| Navigation | NAVIGATION | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;needs&nbsp;to&nbsp;obtain&nbsp;the&nbsp;real-time&nbsp;location&nbsp;of&nbsp;a&nbsp;mobile&nbsp;device&nbsp;outdoors,&nbsp;such&nbsp;as&nbsp;navigation&nbsp;for&nbsp;driving&nbsp;or&nbsp;walking.&nbsp;In&nbsp;this&nbsp;scenario,&nbsp;the&nbsp;GNSS&nbsp;positioning&nbsp;technology&nbsp;is&nbsp;mainly&nbsp;used&nbsp;to&nbsp;ensure&nbsp;the&nbsp;location&nbsp;accuracy.&nbsp;However,&nbsp;due&nbsp;to&nbsp;its&nbsp;limitations,&nbsp;the&nbsp;technology&nbsp;may&nbsp;be&nbsp;unable&nbsp;to&nbsp;provide&nbsp;the&nbsp;location&nbsp;service&nbsp;when&nbsp;navigation&nbsp;is&nbsp;just&nbsp;started&nbsp;or&nbsp;when&nbsp;the&nbsp;user&nbsp;moves&nbsp;into&nbsp;a&nbsp;shielded&nbsp;environment&nbsp;such&nbsp;as&nbsp;indoors&nbsp;or&nbsp;a&nbsp;garage.&nbsp;To&nbsp;resolve&nbsp;this&nbsp;issue,&nbsp;the&nbsp;system&nbsp;uses&nbsp;the&nbsp;network&nbsp;positioning&nbsp;technology&nbsp;as&nbsp;an&nbsp;alternative&nbsp;to&nbsp;provide&nbsp;the&nbsp;location&nbsp;service&nbsp;for&nbsp;your&nbsp;application&nbsp;until&nbsp;the&nbsp;GNSS&nbsp;can&nbsp;provide&nbsp;stable&nbsp;location&nbsp;results.&nbsp;This&nbsp;helps&nbsp;achieve&nbsp;a&nbsp;smooth&nbsp;navigation&nbsp;experience&nbsp;for&nbsp;users.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Trajectory&nbsp;tracking | TRAJECTORY_TRACKING | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;needs&nbsp;to&nbsp;record&nbsp;user&nbsp;trajectories,&nbsp;for&nbsp;example,&nbsp;the&nbsp;track&nbsp;recording&nbsp;function&nbsp;of&nbsp;sports&nbsp;applications.&nbsp;In&nbsp;this&nbsp;scenario,&nbsp;the&nbsp;GNSS&nbsp;positioning&nbsp;technology&nbsp;is&nbsp;mainly&nbsp;used&nbsp;to&nbsp;ensure&nbsp;the&nbsp;location&nbsp;accuracy.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Ride&nbsp;hailing | CAR_HAILING | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;needs&nbsp;to&nbsp;obtain&nbsp;the&nbsp;current&nbsp;location&nbsp;of&nbsp;a&nbsp;user&nbsp;who&nbsp;is&nbsp;hailing&nbsp;a&nbsp;taxi.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Life&nbsp;service | DAILY_LIFE_SERVICE | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;only&nbsp;needs&nbsp;the&nbsp;approximate&nbsp;user&nbsp;location&nbsp;for&nbsp;recommendations&nbsp;and&nbsp;push&nbsp;notifications&nbsp;in&nbsp;scenarios&nbsp;such&nbsp;as&nbsp;when&nbsp;the&nbsp;user&nbsp;is&nbsp;browsing&nbsp;news,&nbsp;shopping&nbsp;online,&nbsp;and&nbsp;ordering&nbsp;food.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Power&nbsp;efficiency | NO_POWER | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;does&nbsp;not&nbsp;proactively&nbsp;start&nbsp;the&nbsp;location&nbsp;service&nbsp;for&nbsp;a&nbsp;higher&nbsp;battery&nbsp;efficiency.&nbsp;When&nbsp;responding&nbsp;to&nbsp;another&nbsp;application&nbsp;requesting&nbsp;the&nbsp;same&nbsp;location&nbsp;service,&nbsp;the&nbsp;system&nbsp;marks&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;location&nbsp;result&nbsp;to&nbsp;your&nbsp;application.&nbsp;In&nbsp;this&nbsp;way,&nbsp;your&nbsp;application&nbsp;will&nbsp;not&nbsp;consume&nbsp;extra&nbsp;power&nbsp;for&nbsp;obtaining&nbsp;the&nbsp;user&nbsp;location.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Navigation | NAVIGATION | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;needs&nbsp;to&nbsp;obtain&nbsp;the&nbsp;real-time&nbsp;location&nbsp;of&nbsp;a&nbsp;mobile&nbsp;device&nbsp;outdoors,&nbsp;such&nbsp;as&nbsp;navigation&nbsp;for&nbsp;driving&nbsp;or&nbsp;walking.&nbsp;In&nbsp;this&nbsp;scenario,&nbsp;the&nbsp;GNSS&nbsp;positioning&nbsp;technology&nbsp;is&nbsp;mainly&nbsp;used&nbsp;to&nbsp;ensure&nbsp;the&nbsp;location&nbsp;accuracy.&nbsp;However,&nbsp;due&nbsp;to&nbsp;its&nbsp;limitations,&nbsp;the&nbsp;technology&nbsp;may&nbsp;be&nbsp;unable&nbsp;to&nbsp;provide&nbsp;the&nbsp;location&nbsp;service&nbsp;when&nbsp;navigation&nbsp;is&nbsp;just&nbsp;started&nbsp;or&nbsp;when&nbsp;the&nbsp;user&nbsp;moves&nbsp;into&nbsp;a&nbsp;shielded&nbsp;environment&nbsp;such&nbsp;as&nbsp;indoors&nbsp;or&nbsp;a&nbsp;garage.&nbsp;To&nbsp;resolve&nbsp;this&nbsp;issue,&nbsp;the&nbsp;system&nbsp;uses&nbsp;the&nbsp;network&nbsp;positioning&nbsp;technology&nbsp;as&nbsp;an&nbsp;alternative&nbsp;to&nbsp;provide&nbsp;the&nbsp;location&nbsp;service&nbsp;for&nbsp;your&nbsp;application&nbsp;until&nbsp;the&nbsp;GNSS&nbsp;can&nbsp;provide&nbsp;stable&nbsp;location&nbsp;results.&nbsp;This&nbsp;helps&nbsp;achieve&nbsp;a&nbsp;smooth&nbsp;navigation&nbsp;experience&nbsp;for&nbsp;users.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Trajectory&nbsp;tracking | TRAJECTORY_TRACKING | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;needs&nbsp;to&nbsp;record&nbsp;user&nbsp;trajectories,&nbsp;for&nbsp;example,&nbsp;the&nbsp;track&nbsp;recording&nbsp;function&nbsp;of&nbsp;sports&nbsp;applications.&nbsp;In&nbsp;this&nbsp;scenario,&nbsp;the&nbsp;GNSS&nbsp;positioning&nbsp;technology&nbsp;is&nbsp;mainly&nbsp;used&nbsp;to&nbsp;ensure&nbsp;the&nbsp;location&nbsp;accuracy.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Ride&nbsp;hailing | CAR_HAILING | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;needs&nbsp;to&nbsp;obtain&nbsp;the&nbsp;current&nbsp;location&nbsp;of&nbsp;a&nbsp;user&nbsp;who&nbsp;is&nbsp;hailing&nbsp;a&nbsp;taxi.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Life&nbsp;service | DAILY_LIFE_SERVICE | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;only&nbsp;needs&nbsp;the&nbsp;approximate&nbsp;user&nbsp;location&nbsp;for&nbsp;recommendations&nbsp;and&nbsp;push&nbsp;notifications&nbsp;in&nbsp;scenarios&nbsp;such&nbsp;as&nbsp;when&nbsp;the&nbsp;user&nbsp;is&nbsp;browsing&nbsp;news,&nbsp;shopping&nbsp;online,&nbsp;and&nbsp;ordering&nbsp;food.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Power&nbsp;efficiency | NO_POWER | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;does&nbsp;not&nbsp;proactively&nbsp;start&nbsp;the&nbsp;location&nbsp;service&nbsp;for&nbsp;a&nbsp;higher&nbsp;battery&nbsp;efficiency.&nbsp;When&nbsp;responding&nbsp;to&nbsp;another&nbsp;application&nbsp;requesting&nbsp;the&nbsp;same&nbsp;location&nbsp;service,&nbsp;the&nbsp;system&nbsp;marks&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;location&nbsp;result&nbsp;to&nbsp;your&nbsp;application.&nbsp;In&nbsp;this&nbsp;way,&nbsp;your&nbsp;application&nbsp;will&nbsp;not&nbsp;consume&nbsp;extra&nbsp;power&nbsp;for&nbsp;obtaining&nbsp;the&nbsp;user&nbsp;location.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
The following example instantiates the **RequestParam** object for navigation:
......@@ -143,11 +141,11 @@ The following table describes APIs available for obtaining device location infor
**Table3** Location priority policies
| Policy | Constant | Description |
| Policy | Constant | Description |
| -------- | -------- | -------- |
| Location&nbsp;accuracy&nbsp;priority | ACCURACY | This&nbsp;policy&nbsp;mainly&nbsp;uses&nbsp;the&nbsp;GNSS&nbsp;positioning&nbsp;technology.&nbsp;In&nbsp;an&nbsp;open&nbsp;area,&nbsp;the&nbsp;technology&nbsp;can&nbsp;achieve&nbsp;the&nbsp;meter-level&nbsp;location&nbsp;accuracy,&nbsp;depending&nbsp;on&nbsp;the&nbsp;hardware&nbsp;performance&nbsp;of&nbsp;the&nbsp;device.&nbsp;However,&nbsp;in&nbsp;a&nbsp;shielded&nbsp;environment,&nbsp;the&nbsp;location&nbsp;accuracy&nbsp;may&nbsp;significantly&nbsp;decrease.<br/>To&nbsp;use&nbsp;this&nbsp;policy,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Fast&nbsp;location&nbsp;priority | FAST_FIRST_FIX | This&nbsp;policy&nbsp;uses&nbsp;the&nbsp;GNSS&nbsp;positioning,&nbsp;base&nbsp;station&nbsp;positioning,&nbsp;WLAN&nbsp;positioning,&nbsp;and&nbsp;Bluetooth&nbsp;positioning&nbsp;technologies&nbsp;simultaneously&nbsp;to&nbsp;obtain&nbsp;the&nbsp;device&nbsp;location&nbsp;in&nbsp;both&nbsp;the&nbsp;indoor&nbsp;and&nbsp;outdoor&nbsp;scenarios.&nbsp;When&nbsp;all&nbsp;positioning&nbsp;technologies&nbsp;provide&nbsp;a&nbsp;location&nbsp;result,&nbsp;the&nbsp;system&nbsp;provides&nbsp;the&nbsp;most&nbsp;accurate&nbsp;location&nbsp;result&nbsp;for&nbsp;your&nbsp;application.&nbsp;This&nbsp;policy&nbsp;can&nbsp;lead&nbsp;to&nbsp;significant&nbsp;hardware&nbsp;resource&nbsp;consumption&nbsp;and&nbsp;power&nbsp;consumption.<br/>To&nbsp;use&nbsp;this&nbsp;policy,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Power&nbsp;efficiency&nbsp;priority | LOW_POWER | This&nbsp;policy&nbsp;mainly&nbsp;uses&nbsp;the&nbsp;base&nbsp;station&nbsp;positioning,&nbsp;WLAN&nbsp;positioning,&nbsp;and&nbsp;Bluetooth&nbsp;positioning&nbsp;technologies&nbsp;to&nbsp;obtain&nbsp;device&nbsp;location&nbsp;in&nbsp;both&nbsp;indoor&nbsp;and&nbsp;outdoor&nbsp;scenarios.&nbsp;The&nbsp;location&nbsp;accuracy&nbsp;depends&nbsp;on&nbsp;the&nbsp;distribution&nbsp;of&nbsp;surrounding&nbsp;base&nbsp;stations,&nbsp;visible&nbsp;WLANs,&nbsp;and&nbsp;Bluetooth&nbsp;devices&nbsp;and&nbsp;therefore&nbsp;may&nbsp;fluctuate&nbsp;greatly.&nbsp;This&nbsp;policy&nbsp;is&nbsp;recommended&nbsp;and&nbsp;can&nbsp;reduce&nbsp;power&nbsp;consumption&nbsp;when&nbsp;your&nbsp;application&nbsp;does&nbsp;not&nbsp;require&nbsp;high&nbsp;location&nbsp;accuracy&nbsp;or&nbsp;when&nbsp;base&nbsp;stations,&nbsp;visible&nbsp;WLANs,&nbsp;and&nbsp;Bluetooth&nbsp;devices&nbsp;are&nbsp;densely&nbsp;distributed.<br/>To&nbsp;use&nbsp;this&nbsp;policy,&nbsp;you&nbsp;must&nbsp;declare&nbsp;at&nbsp;least&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Location&nbsp;accuracy&nbsp;priority | ACCURACY | This&nbsp;policy&nbsp;mainly&nbsp;uses&nbsp;the&nbsp;GNSS&nbsp;positioning&nbsp;technology.&nbsp;In&nbsp;an&nbsp;open&nbsp;area,&nbsp;the&nbsp;technology&nbsp;can&nbsp;achieve&nbsp;the&nbsp;meter-level&nbsp;location&nbsp;accuracy,&nbsp;depending&nbsp;on&nbsp;the&nbsp;hardware&nbsp;performance&nbsp;of&nbsp;the&nbsp;device.&nbsp;However,&nbsp;in&nbsp;a&nbsp;shielded&nbsp;environment,&nbsp;the&nbsp;location&nbsp;accuracy&nbsp;may&nbsp;significantly&nbsp;decrease.<br/>To&nbsp;use&nbsp;this&nbsp;policy,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Fast&nbsp;location&nbsp;priority | FAST_FIRST_FIX | This&nbsp;policy&nbsp;uses&nbsp;the&nbsp;GNSS&nbsp;positioning,&nbsp;base&nbsp;station&nbsp;positioning,&nbsp;WLAN&nbsp;positioning,&nbsp;and&nbsp;Bluetooth&nbsp;positioning&nbsp;technologies&nbsp;simultaneously&nbsp;to&nbsp;obtain&nbsp;the&nbsp;device&nbsp;location&nbsp;in&nbsp;both&nbsp;the&nbsp;indoor&nbsp;and&nbsp;outdoor&nbsp;scenarios.&nbsp;When&nbsp;all&nbsp;positioning&nbsp;technologies&nbsp;provide&nbsp;a&nbsp;location&nbsp;result,&nbsp;the&nbsp;system&nbsp;provides&nbsp;the&nbsp;most&nbsp;accurate&nbsp;location&nbsp;result&nbsp;for&nbsp;your&nbsp;application.&nbsp;This&nbsp;policy&nbsp;can&nbsp;lead&nbsp;to&nbsp;significant&nbsp;hardware&nbsp;resource&nbsp;consumption&nbsp;and&nbsp;power&nbsp;consumption.<br/>To&nbsp;use&nbsp;this&nbsp;policy,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
| Power&nbsp;efficiency&nbsp;priority | LOW_POWER | This&nbsp;policy&nbsp;mainly&nbsp;uses&nbsp;the&nbsp;base&nbsp;station&nbsp;positioning,&nbsp;WLAN&nbsp;positioning,&nbsp;and&nbsp;Bluetooth&nbsp;positioning&nbsp;technologies&nbsp;to&nbsp;obtain&nbsp;device&nbsp;location&nbsp;in&nbsp;both&nbsp;indoor&nbsp;and&nbsp;outdoor&nbsp;scenarios.&nbsp;The&nbsp;location&nbsp;accuracy&nbsp;depends&nbsp;on&nbsp;the&nbsp;distribution&nbsp;of&nbsp;surrounding&nbsp;base&nbsp;stations,&nbsp;visible&nbsp;WLANs,&nbsp;and&nbsp;Bluetooth&nbsp;devices&nbsp;and&nbsp;therefore&nbsp;may&nbsp;fluctuate&nbsp;greatly.&nbsp;This&nbsp;policy&nbsp;is&nbsp;recommended&nbsp;and&nbsp;can&nbsp;reduce&nbsp;power&nbsp;consumption&nbsp;when&nbsp;your&nbsp;application&nbsp;does&nbsp;not&nbsp;require&nbsp;high&nbsp;location&nbsp;accuracy&nbsp;or&nbsp;when&nbsp;base&nbsp;stations,&nbsp;visible&nbsp;WLANs,&nbsp;and&nbsp;Bluetooth&nbsp;devices&nbsp;are&nbsp;densely&nbsp;distributed.<br/>To&nbsp;use&nbsp;this&nbsp;policy,&nbsp;you&nbsp;must&nbsp;declare&nbsp;at&nbsp;least&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. |
The following example instantiates the **RequestParam** object for the location accuracy priority policy:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册