提交 637057ae 编写于 作者: S shawn_he

update doc

Signed-off-by: Nshawn_he <shawn.he@huawei.com>
上级 a2664050
...@@ -33,7 +33,7 @@ The APIs are used for troubleshooting and do not return any exception. Therefore ...@@ -33,7 +33,7 @@ The APIs are used for troubleshooting and do not return any exception. Therefore
Fault management is an important way for applications to deliver a better user experience. The application framework offers three methods for application fault management: fault listening, fault rectification, and fault query. Fault management is an important way for applications to deliver a better user experience. The application framework offers three methods for application fault management: fault listening, fault rectification, and fault query.
- Fault listening refers to the process of registering [ErrorObserver](../reference/apis/js-apis-application-errorManager.md#errorobserver) via [errorManager](../reference/apis/js-apis-application-errorManager.md), listening for fault occurrence, and notifying the fault listener. - Fault listening refers to the process of registering [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) via [errorManager](../reference/apis/js-apis-app-ability-errorManager.md), listening for fault occurrence, and notifying the fault listener.
- Fault rectification refers to [appRecovery](../reference/apis/js-apis-app-ability-appRecovery.md) and restarts an application to restore its status previous to a fault. - Fault rectification refers to [appRecovery](../reference/apis/js-apis-app-ability-appRecovery.md) and restarts an application to restore its status previous to a fault.
...@@ -42,8 +42,8 @@ Fault management is an important way for applications to deliver a better user e ...@@ -42,8 +42,8 @@ Fault management is an important way for applications to deliver a better user e
The figure below does not illustrate the time when [faultLogger](../reference/apis/js-apis-faultLogger.md) is called. You can refer to [LastExitReason](../reference/apis/js-apis-application-abilityConstant.md#abilityconstantlastexitreason) passed during application initialization to determine whether to call [faultLogger](../reference/apis/js-apis-faultLogger.md) to query the information about the last fault. The figure below does not illustrate the time when [faultLogger](../reference/apis/js-apis-faultLogger.md) is called. You can refer to [LastExitReason](../reference/apis/js-apis-application-abilityConstant.md#abilityconstantlastexitreason) passed during application initialization to determine whether to call [faultLogger](../reference/apis/js-apis-faultLogger.md) to query the information about the last fault.
![Fault rectification process](./figures/fault_rectification.png) ![Fault rectification process](./figures/fault_rectification.png)
It is recommended that you call [errorManager](../reference/apis/js-apis-application-errorManager.md) to process the exception. After the processing is complete, you can call the status saving API and restart the application. It is recommended that you call [errorManager](../reference/apis/js-apis-app-ability-errorManager.md) to process the exception. After the processing is complete, you can call the status saving API and restart the application.
If you do not register [ErrorObserver](../reference/apis/js-apis-application-errorManager.md#errorobserver) or enable application recovery, the application process will exit according to the default processing logic of the system. Users can restart the application from the home screen. If you do not register [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) or enable application recovery, the application process will exit according to the default processing logic of the system. Users can restart the application from the home screen.
If you have enabled application recovery, the framework first checks whether a fault allows for ability status saving and whether you have configured ability status saving. If so, [onSaveState](../reference/apis/js-apis-application-ability.md#abilityonsavestate) of [Ability](../reference/apis/js-apis-application-ability.md#ability) is called back. Finally, the application is restarted. If you have enabled application recovery, the framework first checks whether a fault allows for ability status saving and whether you have configured ability status saving. If so, [onSaveState](../reference/apis/js-apis-application-ability.md#abilityonsavestate) of [Ability](../reference/apis/js-apis-application-ability.md#ability) is called back. Finally, the application is restarted.
### Scenarios Supported by Application Fault Management APIs ### Scenarios Supported by Application Fault Management APIs
...@@ -95,7 +95,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant' ...@@ -95,7 +95,7 @@ import AbilityConstant from '@ohos.app.ability.AbilityConstant'
#### Actively Saving Status and Restoring Data #### Actively Saving Status and Restoring Data
- Define and register the [ErrorObserver](../reference/apis/js-apis-application-errorManager.md#errorobserver) callback. - Define and register the [ErrorObserver](../reference/apis/js-apis-inner-application-errorObserver.md) callback.
```ts ```ts
var registerId = -1; var registerId = -1;
......
...@@ -240,7 +240,7 @@ Users in different regions have different requirements for string sorting. [Coll ...@@ -240,7 +240,7 @@ Users in different regions have different requirements for string sorting. [Coll
let collator = new Intl.Collator(); let collator = new Intl.Collator();
``` ```
Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions8). Alternatively, use your own locale and formatting parameters to create a **Collator** object. For a full list of parameters, see [CollatorOptions](../reference/apis/js-apis-intl.md#collatoroptions9).
The **sensitivity** parameter is used to specify the levels of differences that will be used for string comparison. The value **base** indicates that only characters are compared, but not the accent and capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **accent** indicates that the accent is considered, but not the capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **case** indicates that the capitalization is considered, but the accent. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **variant** indicates that the accent and capitalization are considered. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The **sensitivity** parameter is used to specify the levels of differences that will be used for string comparison. The value **base** indicates that only characters are compared, but not the accent and capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **accent** indicates that the accent is considered, but not the capitalization. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **case** indicates that the capitalization is considered, but the accent. For example, 'a' != 'b', 'a' == '', 'a'=='A'. The value **variant** indicates that the accent and capitalization are considered. For example, 'a' != 'b', 'a' == '', 'a'=='A'.
```js ```js
...@@ -301,7 +301,7 @@ According to grammars in certain languages, the singular or plural form of a nou ...@@ -301,7 +301,7 @@ According to grammars in certain languages, the singular or plural form of a nou
let pluralRules = new Intl.PluralRules(); let pluralRules = new Intl.PluralRules();
``` ```
Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions8). Alternatively, use your own locale and formatting parameters to create a **PluralRules** object. For a full list of parameters, see [PluralRulesOptions](../reference/apis/js-apis-intl.md#pluralrulesoptions9).
```js ```js
let pluralRules = new Intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"}); let pluralRules = new Intl.PluralRules("zh-CN", {localeMatcher: "best fit", type: "cardinal"});
...@@ -349,7 +349,7 @@ According to grammars in certain languages, the singular or plural form of a nou ...@@ -349,7 +349,7 @@ According to grammars in certain languages, the singular or plural form of a nou
let relativeTimeFormat = new Intl.RelativeTimeFormat(); let relativeTimeFormat = new Intl.RelativeTimeFormat();
``` ```
Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions8). Alternatively, use your own locale and formatting parameters to create a **RelativeTimeFormat** object. Formatting parameters are optional. For a full list of formatting parameters, see [RelativeTimeFormatInputOptions](../reference/apis/js-apis-intl.md#relativetimeformatinputoptions9).
```js ```js
let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"}); let relativeTimeFormat = new Intl.RelativeTimeFormat("zh-CN", {numeric: "always", style: "long"});
......
...@@ -20,6 +20,10 @@ dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void ...@@ -20,6 +20,10 @@ dial\(phoneNumber: string, callback: AsyncCallback<boolean\>\): void
Initiates a call. This API uses an asynchronous callback to return the result. Initiates a call. This API uses an asynchronous callback to return the result.
>**NOTE**
>
>This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9).
**Required Permissions**: ohos.permission.PLACE_CALL **Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -46,6 +50,10 @@ dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean ...@@ -46,6 +50,10 @@ dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean
Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result. Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result.
>**NOTE**
>
>This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9).
**Required Permissions**: ohos.permission.PLACE_CALL **Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -75,6 +83,10 @@ dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\> ...@@ -75,6 +83,10 @@ dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\>
Initiates a call. You can set call options as needed. This API uses a promise to return the result. Initiates a call. You can set call options as needed. This API uses a promise to return the result.
>**NOTE**
>
>This parameter is supported since API version 6 and deprecated since API version 9. You are advised to use [dialCall](#calldialcall9).
**Required Permissions**: ohos.permission.PLACE_CALL **Required Permissions**: ohos.permission.PLACE_CALL
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -123,7 +135,7 @@ Initiates a call. This API uses an asynchronous callback to return the result. ...@@ -123,7 +135,7 @@ Initiates a call. This API uses an asynchronous callback to return the result.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ---------------------------- | ---- | --------------------------------------- | | ----------- | ---------------------------- | ---- | --------------------------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md). For details about the following error codes, see [Telephony Error Codes](../../reference/errorcodes/errorcode-telephony.md).
...@@ -206,10 +218,10 @@ Initiates a call. You can set call options as needed. This API uses a promise to ...@@ -206,10 +218,10 @@ Initiates a call. You can set call options as needed. This API uses a promise to
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ----------- | ----------------------------------- | ---- | -------------------------------------- | | ----------- | ----------------------------------- | ---- |-------------------|
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | [DialCallOptions](#dialcalloptions9)| No | Call option, which indicates whether the call is a voice call or video call.| | options | [DialCallOptions](#dialcalloptions9)| No | Call options, which carry other configuration information of the call.|
**Return value** **Return value**
...@@ -232,12 +244,22 @@ For details about the following error codes, see [Telephony Error Codes](../../r ...@@ -232,12 +244,22 @@ For details about the following error codes, see [Telephony Error Codes](../../r
**Example** **Example**
```js ```js
try { let promise = call.dialCall("138xxxxxxxx", {
call.dialCall('138xxxxxxxx'); call.dialCall('138xxxxxxxx');
accountId: 0,
videoState: 0,
dialScene: 0,
dialType: 0,
});
promise.then(data => {
console.log(`dialCall success, promise: data->${JSON.stringify(data)}`);
console.log(`dialCall success, promise: data->${JSON.stringify(data)}`); console.log(`dialCall success, promise: data->${JSON.stringify(data)}`);
} catch (error) { } catch (error) {
}).catch(err => {
console.log(`dialCall fail, promise: err->${JSON.stringify(error)}`); console.log(`dialCall fail, promise: err->${JSON.stringify(error)}`);
console.error(`dialCall fail, promise: err->${JSON.stringify(err)}`);
} }
});
``` ```
...@@ -836,7 +858,7 @@ promise.then(data => { ...@@ -836,7 +858,7 @@ promise.then(data => {
``` ```
## call.answerCall<sup>7+</sup> ## call.answerCall<sup>9+</sup>
answerCall\(callId: number, callback: AsyncCallback<void\>\): void answerCall\(callId: number, callback: AsyncCallback<void\>\): void
...@@ -876,7 +898,7 @@ call.answerCall(1, (err, data) => { ...@@ -876,7 +898,7 @@ call.answerCall(1, (err, data) => {
``` ```
## call.answerCall<sup>7+</sup> ## call.answerCall<sup>9+</sup>
answerCall(callId?: number\): Promise<void\> answerCall(callId?: number\): Promise<void\>
...@@ -963,7 +985,7 @@ call.answerCall((err, data) => { ...@@ -963,7 +985,7 @@ call.answerCall((err, data) => {
``` ```
## call.hangUpCall<sup>7+</sup> ## call.hangUpCall<sup>9+</sup>
hangUpCall\(callId: number, callback: AsyncCallback<void\>\): void hangUpCall\(callId: number, callback: AsyncCallback<void\>\): void
...@@ -1003,7 +1025,7 @@ call.hangUpCall(1, (err, data) => { ...@@ -1003,7 +1025,7 @@ call.hangUpCall(1, (err, data) => {
``` ```
## call.hangUpCall<sup>7+</sup> ## call.hangUpCall<sup>9+</sup>
hangUpCall\(callId?: number\): Promise<void\> hangUpCall\(callId?: number\): Promise<void\>
...@@ -1132,7 +1154,7 @@ call.rejectCall(1, (err, data) => { ...@@ -1132,7 +1154,7 @@ call.rejectCall(1, (err, data) => {
``` ```
## call.rejectCall<sup>7+</sup> ## call.rejectCall<sup>9+</sup>
rejectCall\(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void\>\): void rejectCall\(callId: number, options: RejectMessageOptions, callback: AsyncCallback<void\>\): void
...@@ -1176,7 +1198,7 @@ call.rejectCall(1, rejectMessageOptions, (err, data) => { ...@@ -1176,7 +1198,7 @@ call.rejectCall(1, rejectMessageOptions, (err, data) => {
``` ```
## call.rejectCall<sup>7+</sup> ## call.rejectCall<sup>9+</sup>
rejectCall(callId?: number, options?: RejectMessageOptions\): Promise<void\> rejectCall(callId?: number, options?: RejectMessageOptions\): Promise<void\>
...@@ -2332,7 +2354,7 @@ Subscribes to **callDetailsChange** events. This API uses an asynchronous callba ...@@ -2332,7 +2354,7 @@ Subscribes to **callDetailsChange** events. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------- | ---- | -------------------------- | | -------- | ------------------------------------------------------- | ---- | -------------------------- |
| type | string | Yes | Call details change during a call.| | type | string | Yes | Call details change.|
| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. | | callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2371,7 +2393,7 @@ Subscribes to **callEventChange** events. This API uses an asynchronous callback ...@@ -2371,7 +2393,7 @@ Subscribes to **callEventChange** events. This API uses an asynchronous callback
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------------- | | -------- | ------------------------------------------------ | ---- | -------------------------- |
| type | string | Yes | Call event change during a call.| | type | string | Yes | Call event change.|
| callback | Callback<[CallEventOptions](#calleventoptions8)> | Yes | Callback used to return the result. | | callback | Callback<[CallEventOptions](#calleventoptions8)> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2410,7 +2432,7 @@ Subscribes to **callDisconnectedCause** events. This API uses an asynchronous ca ...@@ -2410,7 +2432,7 @@ Subscribes to **callDisconnectedCause** events. This API uses an asynchronous ca
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------ | ---- | -------------------------- | | -------- | ------------------------------------------------------ | ---- | -------------------------- |
| type | string | Yes | Cause of the call disconnection.| | type | string | Yes | Call disconnection cause.|
| callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | Yes | Callback used to return the result. | | callback | Callback<[DisconnectedDetails](#disconnecteddetails9)> | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2488,7 +2510,7 @@ Unsubscribes from **callDetailsChange** events. This API uses an asynchronous ca ...@@ -2488,7 +2510,7 @@ Unsubscribes from **callDetailsChange** events. This API uses an asynchronous ca
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------------- | ---- | ---------------------------------- | | -------- | -------------------------------------------------------- | ---- | ---------------------------------- |
| type | string | Yes | IMS registration status changes.| | type | string | Yes | IMS registration status change.|
| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. | | callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2527,7 +2549,7 @@ Unsubscribes from **callEventChange** events. This API uses an asynchronous call ...@@ -2527,7 +2549,7 @@ Unsubscribes from **callEventChange** events. This API uses an asynchronous call
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ---------------------------------- | | -------- | ------------------------------------------------ | ---- | ---------------------------------- |
| type | string | Yes | Unsubscription from call event changes when a call ends.| | type | string | Yes | Call event change.|
| callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. | | callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2566,7 +2588,7 @@ Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronou ...@@ -2566,7 +2588,7 @@ Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronou
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------------- | ---- | -------------------- | | -------- | ---------------------------------------------------------- | ---- | -------------------- |
| type | 'callDisconnectedCause' | Yes | Unsubscription from the call disconnection cause when a call ends.| | type | 'callDisconnectedCause' | Yes | Call disconnection cause.|
| callback | Callback**<**[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. | | callback | Callback**<**[DisconnectedDetails](#disconnecteddetails9)> | No | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -2605,7 +2627,7 @@ Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callba ...@@ -2605,7 +2627,7 @@ Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callba
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ----------- | | -------- | ------------------------------------------------ | ---- | ----------- |
| type | 'mmiCodeResult' | Yes | MMI code result.| | type | 'mmiCodeResult' | Yes | Defines the MMI code result.|
| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. | | callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. |
**Error codes** **Error codes**
......
...@@ -280,7 +280,7 @@ Sets the priority of the location request. ...@@ -280,7 +280,7 @@ Sets the priority of the location request.
| Name| Value| Description| | Name| Value| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| UNSET | 0x300 | Scenario unspecified.<br>If this option is used, [LocationRequestScenario](#locationrequest scenario) is invalid.| | UNSET | 0x300 | Scenario unspecified.<br>If this option is used, [LocationRequestScenario](#locationrequestscenario) is invalid.|
| NAVIGATION | 0x301 | Navigation scenario.<br>This option is applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking.<br>In this scenario, GNSS positioning is used to provide location services to ensure the optimal location accuracy of the system.<br>The location result is reported at a minimum interval of 1 second by default.| | NAVIGATION | 0x301 | Navigation scenario.<br>This option is applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking.<br>In this scenario, GNSS positioning is used to provide location services to ensure the optimal location accuracy of the system.<br>The location result is reported at a minimum interval of 1 second by default.|
| TRAJECTORY_TRACKING | 0x302 | Trajectory tracking scenario.<br>This option is applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.<br>The location result is reported at a minimum interval of 1 second by default.| | TRAJECTORY_TRACKING | 0x302 | Trajectory tracking scenario.<br>This option is applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.<br>The location result is reported at a minimum interval of 1 second by default.|
| CAR_HAILING | 0x303 | Ride hailing scenario.<br>This option is applicable when your application needs to obtain the current location of a user who is hailing a taxi.<br>The location result is reported at a minimum interval of 1 second by default.| | CAR_HAILING | 0x303 | Ride hailing scenario.<br>This option is applicable when your application needs to obtain the current location of a user who is hailing a taxi.<br>The location result is reported at a minimum interval of 1 second by default.|
...@@ -882,7 +882,6 @@ For details about the following error codes, see [Location Error Codes](../error ...@@ -882,7 +882,6 @@ For details about the following error codes, see [Location Error Codes](../error
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
|3301000 | Location service is unavailable. | |3301000 | Location service is unavailable. |
|3301100 | The location switch is off. |
|3301500 | Failed to query the area information. | |3301500 | Failed to query the area information. |
...@@ -924,7 +923,6 @@ For details about the following error codes, see [Location Error Codes](../error ...@@ -924,7 +923,6 @@ For details about the following error codes, see [Location Error Codes](../error
| ID| Error Message| | ID| Error Message|
| -------- | ---------------------------------------- | | -------- | ---------------------------------------- |
|3301000 | Location service is unavailable. | |3301000 | Location service is unavailable. |
|3301100 | The location switch is off. |
|3301500 | Failed to query the area information. | |3301500 | Failed to query the area information. |
**Example** **Example**
......
...@@ -21,44 +21,22 @@ ohos.permission.LOCATION ...@@ -21,44 +21,22 @@ ohos.permission.LOCATION
## geolocation.getLocation<sup>(deprecated)</sup> ## geolocation.getLocation<sup>(deprecated)</sup>
getLocation(Object): void getLocation(options?: GetLocationOption): void
Obtains the geographic location. Obtains the geographic location.
> **NOTE** > **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation). > This API is deprecated since API version 9. You are advised to use [geoLocationManager.getCurrentLocation](js-apis-geoLocationManager.md#geolocationmanagergetcurrentlocation).
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Lite **System capability**: SystemCapability.Location.Location.Lite
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| timeout | number | No| Timeout duration, in ms. The default value is **30000**.<br>The timeout duration is necessary in case the request to obtain the geographic location is rejected for the lack of the required permission, weak positioning signal, or incorrect location settings. After the timeout duration expires, the fail function will be called.<br>The value is a 32-digit positive integer. If the specified value is less than or equal to **0**, the default value will be used.| | options | [GetLocationOption](#getlocationoptiondeprecated) | No| Options of a single location request.|
| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.|
| success | Function | No| Called when API call is successful.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
**Return value of success()**
| Name| Type| Description|
| -------- | -------- | -------- |
| longitude | number | Longitude.|
| latitude | number | Latitude.|
| altitude | number | Altitude.|
| accuracy | number | Location accuracy.|
| time | number | Time when the location is obtained.|
**Return value of fail()**
| Error Code| Description|
| -------- | -------- |
| 601 | Failed to obtain the required permission because the user rejected the request.|
| 602 | Permission not declared.|
| 800 | Operation times out due to a poor network condition or GNSS unavailability.|
| 801 | System location disabled.|
| 802 | API called again while the previous execution result is not returned yet.|
**Example** **Example**
...@@ -80,7 +58,7 @@ export default { ...@@ -80,7 +58,7 @@ export default {
## geolocation.getLocationType<sup>(deprecated)</sup> ## geolocation.getLocationType<sup>(deprecated)</sup>
getLocationType(Object): void getLocationType(options?: GetLocationTypeOption): void
Obtains the supported location types. Obtains the supported location types.
...@@ -93,15 +71,7 @@ Obtains the supported location types. ...@@ -93,15 +71,7 @@ Obtains the supported location types.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| success | Function | No| Called when API call is successful.| | options | [GetLocationTypeOption](#getlocationtypeoptiondeprecated) | No| Callback used to return the result.|
| fail | Function | No| Called when API call has failed.|
| complete | Function | No| Called when API call is complete.|
**Return value of success()**
| Name| Type| Description|
| -------- | -------- | -------- |
| types | Array&lt;string&gt; | Available location types, ['gps', 'network']|
**Example** **Example**
...@@ -123,40 +93,22 @@ export default { ...@@ -123,40 +93,22 @@ export default {
## geolocation.subscribe<sup>(deprecated)</sup> ## geolocation.subscribe<sup>(deprecated)</sup>
subscribe(Object): void subscribe(options: SubscribeLocationOption): void
Listens to the geographic location. If this method is called multiple times, the last call takes effect. Listens to the geographic location. If this method is called multiple times, the last call takes effect.
> **NOTE** > **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('locationChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationchange). > This API is deprecated since API version 9. You are advised to use [geoLocationManager.on('locationChange')](js-apis-geoLocationManager.md#geolocationmanageronlocationchange).
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Lite **System capability**: SystemCapability.Location.Location.Lite
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.| | options | [SubscribeLocationOption](#subscribelocationoptiondeprecated) | Yes| Options for continuous location.|
| success | Function | Yes| Called when the geographic location changes.|
| fail | Function | No| Called when API call has failed.|
**Return value of success()**
| Name| Type| Description|
| -------- | -------- | -------- |
| longitude | number | Longitude.|
| latitude | number | Latitude.|
| altitude | number | Altitude.|
| accuracy | number | Location accuracy.|
| time | number | Time when the location is obtained.|
**Return value of fail()**
| Error Code| Description|
| -------- | -------- |
| 601 | Failed to obtain the required permission because the user rejected the request.|
| 602 | Permission not declared.|
| 801 | System location disabled.|
**Example** **Example**
...@@ -185,6 +137,8 @@ Cancels listening to the geographic location. ...@@ -185,6 +137,8 @@ Cancels listening to the geographic location.
> **NOTE** > **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('locationChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationchange). > This API is deprecated since API version 9. You are advised to use [geoLocationManager.off('locationChange')](js-apis-geoLocationManager.md#geolocationmanagerofflocationchange).
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Lite **System capability**: SystemCapability.Location.Location.Lite
**Example** **Example**
...@@ -224,3 +178,102 @@ export default { ...@@ -224,3 +178,102 @@ export default {
}, },
} }
``` ```
## GetLocationOption<sup>(deprecated)</sup>
Defines the options of a single location request.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.CurrentLocationRequest](js-apis-geoLocationManager.md#CurrentLocationRequest).
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Lite
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| timeout | number | No| Timeout duration, in ms. The default value is **30000**.<br>The timeout duration is necessary in case the request to obtain the geographic location is rejected for the lack of the required permission, weak positioning signal, or incorrect location settings. After the timeout duration expires, the fail function will be called.<br>The value is a 32-digit positive integer. If the specified value is less than or equal to **0**, the default value will be used.|
| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.|
| success | (data: [GeolocationResponse](#geolocationresponsedeprecated)) => void | No| Called when API call is successful.|
| fail | (data: string, code: number) => void | No| Called when API call has failed. **data** indicates the error information, and **code** indicates the error code.|
| complete | () => void | No| Called when API call is complete.|
**Return value of fail()**
| Error Code| Description|
| -------- | -------- |
| 601 | Failed to obtain the required permission because the user rejected the request.|
| 602 | Permission not declared.|
| 800 | Operation times out due to a poor network condition or GNSS unavailability.|
| 801 | System location disabled.|
| 802 | API called again while the previous execution result is not returned yet.|
## GeolocationResponse<sup>(deprecated)</sup>
Defines the location information, including the longitude, latitude, and location precision.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.Location](js-apis-geoLocationManager.md#location).
**System capability**: SystemCapability.Location.Location.Lite
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| longitude | number | Yes| No| Longitude.|
| latitude | number | Yes| No| Latitude.|
| altitude | number | Yes| No| Altitude.|
| accuracy | number | Yes| No| Location accuracy.|
| time | number | Yes| No| Time when the location is obtained.|
## GetLocationTypeOption<sup>(deprecated)</sup>
Defines the location type option, which holds the callback function used to return the query result.
> **NOTE**
> This API is deprecated since API version 9.
**System capability**: SystemCapability.Location.Location.Lite
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| success | (data: [GetLocationTypeResponse](#getlocationtyperesponsedeprecated)) => void | No| Called when API call is successful.|
| fail | (data: string, code: number) => void | No| Called when API call has failed.|
| complete | () => void | No| Called when API call is complete.|
## GetLocationTypeResponse<sup>(deprecated)</sup>
Defines the list of location types supported by the current device
> **NOTE**
> This API is deprecated since API version 9.
**System capability**: SystemCapability.Location.Location.Lite
| Name| Type| Readable| Writable| Description|
| -------- | -------- | -------- | -------- | -------- |
| types | Array&lt;string&gt; | Yes| No| Available location types, ['gps', 'network']|
## SubscribeLocationOption<sup>(deprecated)</sup>
Defines the options for continuous location.
> **NOTE**
> This API is deprecated since API version 9. You are advised to use [geoLocationManager.CurrentLocationRequest](js-apis-geoLocationManager.md#locationrequest).
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Location.Location.Lite
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| coordType | string | No| Coordinate system type. Available types can be obtained by **getSupportedCoordTypes**. The default type is **wgs84**.|
| success | (data: [GeolocationResponse](#geolocationresponsedeprecated)) => void | Yes| Called when the geographic location changes.|
| fail | (data: string, code: number) => void | No| Called when API call has failed.|
**Return value of fail()**
| Error Code| Description|
| -------- | -------- |
| 601 | Failed to obtain the required permission because the user rejected the request.|
| 602 | Permission not declared.|
| 801 | System location disabled.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册