<td class="cellrowborder" valign="top" width="68%"><p id="p1998432514020"><a name="p1998432514020"></a><a name="p1998432514020"></a>Bundle name of the application. It uniquely identifies the application.</p>
<td class="cellrowborder" valign="top" width="69.72697269726973%" headers="mcps1.2.4.1.3 "><p id="p37010510548"><a name="p37010510548"></a><a name="p37010510548"></a>Current language of the application, for example, <strong id="b1260120418488"><a name="b1260120418488"></a><a name="b1260120418488"></a>zh</strong>.</p>
<td class="cellrowborder" valign="top" width="69.72697269726973%" headers="mcps1.2.4.1.3 "><p id="p33321417565"><a name="p33321417565"></a><a name="p33321417565"></a>Text layout direction. Available values are as follows:</p>
<a name="ul1861816241119"></a><a name="ul1861816241119"></a><ul id="ul1861816241119"><li><strong id="b16720155216481"><a name="b16720155216481"></a><a name="b16720155216481"></a>ltr</strong>: The text direction is from left to right.</li><li><strong id="b1910563194919"><a name="b1910563194919"></a><a name="b1910563194919"></a>rtl</strong>: The text direction is from right to left.</li></ul>
<td class="cellrowborder" valign="top" width="69.72697269726973%" headers="mcps1.2.4.1.3 "><p id="p97106183311"><a name="p97106183311"></a><a name="p97106183311"></a>Unicode key set determined by the locale.</p>
<p id="p213145115319"><a name="p213145115319"></a><a name="p213145115319"></a>For example, <strong id="b14471162633518"><a name="b14471162633518"></a><a name="b14471162633518"></a>{"nu":"arab"}</strong> indicates that the current locale uses Arabic numerals.</p>
<p id="p849701364"><a name="p849701364"></a><a name="p849701364"></a>If the current locale does not have a specific key set, an empty set is returned.</p>
>The initial APIs of this module are supported since API version 4. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Module to Import<a name="s1fada83813e64efcbc67e970ced86588"></a>
<td class="cellrowborder" valign="top" width="62%" headers="mcps1.1.5.1.4 "><p id="aac09f7fe897d4a80ab7160590b544e39"><a name="aac09f7fe897d4a80ab7160590b544e39"></a><a name="aac09f7fe897d4a80ab7160590b544e39"></a>Duration of the toast dialog box. The default value is <strong id="b9361121192413"><a name="b9361121192413"></a><a name="b9361121192413"></a>1500</strong>. The recommended value ranges from 1500 ms to 10000 ms.</p>
<div class="note" id="note116191623191316"><a name="note116191623191316"></a><a name="note116191623191316"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p1961942320133"><a name="p1961942320133"></a><a name="p1961942320133"></a>A value less than 1500 is automatically changed to 1500. The maximum value is 10000 ms.</p>
<td class="cellrowborder" valign="top" width="62%" headers="mcps1.1.5.1.4 "><p id="p1120212312365"><a name="p1120212312365"></a><a name="p1120212312365"></a>Distance between the dialog border and the bottom of the screen.</p>
<div class="note" id="note1834105155712"><a name="note1834105155712"></a><a name="note1834105155712"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p10341651115711"><a name="p10341651115711"></a><a name="p10341651115711"></a>This parameter is only supported on phones and tablets.</p>
<td class="cellrowborder" valign="top" width="65%" headers="mcps1.1.5.1.4 "><p id="a3c44052f536c4baead681acbce5dc790"><a name="a3c44052f536c4baead681acbce5dc790"></a><a name="a3c44052f536c4baead681acbce5dc790"></a>Title of the text to display.</p>
<td class="cellrowborder" valign="top" width="65%" headers="mcps1.1.5.1.4 "><p id="ab6529e91fe1d4adc8cb3fa2e531369a9"><a name="ab6529e91fe1d4adc8cb3fa2e531369a9"></a><a name="ab6529e91fe1d4adc8cb3fa2e531369a9"></a>Array of buttons in the dialog box. The array structure is <strong id="b12386125113268"><a name="b12386125113268"></a><a name="b12386125113268"></a>{text:'button', color: '#666666'}</strong>. One to three buttons are supported. The first button is of the <strong id="b192581358288"><a name="b192581358288"></a><a name="b192581358288"></a>positiveButton</strong> type, the second is of the <strong id="b117326710282"><a name="b117326710282"></a><a name="b117326710282"></a>negativeButton</strong> type, and the third is of the <strong id="b4971171010297"><a name="b4971171010297"></a><a name="b4971171010297"></a>neutralButton</strong> type.</p>
<td class="cellrowborder" valign="top" width="65%" headers="mcps1.1.5.1.4 "><p id="a986abb2e067742f3b9fe575e7cbd0224"><a name="a986abb2e067742f3b9fe575e7cbd0224"></a><a name="a986abb2e067742f3b9fe575e7cbd0224"></a>Called when the dialog box is displayed. For the return value, see <a href="#t5f0df2fad0544e3eb458936109014414">return values of the success callback</a>.</p>
<td class="cellrowborder" valign="top" width="65%" headers="mcps1.1.5.1.4 "><p id="a08b61cefc2cb4fed83e6ef32d9056fa7"><a name="a08b61cefc2cb4fed83e6ef32d9056fa7"></a><a name="a08b61cefc2cb4fed83e6ef32d9056fa7"></a>Called when the operation is cancelled.</p>
<td class="cellrowborder" valign="top" width="65%" headers="mcps1.1.5.1.4 "><p id="afcf4c75ba59a40c39e0b848df14c4b51"><a name="afcf4c75ba59a40c39e0b848df14c4b51"></a><a name="afcf4c75ba59a40c39e0b848df14c4b51"></a>Called when the dialog box is closed.</p>
<td class="cellrowborder" valign="top" width="75%" headers="mcps1.1.4.1.3 "><p id="aab61e7c297034494ab27e6ca91102568"><a name="aab61e7c297034494ab27e6ca91102568"></a><a name="aab61e7c297034494ab27e6ca91102568"></a>Index of the selected button in the buttons array</p>
<td class="cellrowborder" valign="top" width="52.65%" headers="mcps1.1.5.1.4 "><p id="p201915217358"><a name="p201915217358"></a><a name="p201915217358"></a>Title of the text to display.</p>
<td class="cellrowborder" valign="top" width="52.65%" headers="mcps1.1.5.1.4 "><p id="p191911293517"><a name="p191911293517"></a><a name="p191911293517"></a>Array of buttons in the dialog box. The array structure is <strong id="b195031228114514"><a name="b195031228114514"></a><a name="b195031228114514"></a>{text:'button', color: '#666666'}</strong>. One to six buttons are supported. If there are more than six buttons, the pop-up window will not be displayed.</p>
<td class="cellrowborder" valign="top" width="52.65%" headers="mcps1.1.5.1.4 "><p id="p920321358"><a name="p920321358"></a><a name="p920321358"></a>Called when the operation is successful.</p>
<td class="cellrowborder" valign="top" width="52.65%" headers="mcps1.1.5.1.4 "><p id="p192110273519"><a name="p192110273519"></a><a name="p192110273519"></a>Called when the operation is complete.</p>
<td class="cellrowborder" valign="top" width="75%" headers="mcps1.2.4.1.3 "><p id="p16221326352"><a name="p16221326352"></a><a name="p16221326352"></a>Index of the selected button in the buttons array, starting from 0.</p>
>Page routing APIs can be invoked only after page rendering is complete. Do not call the APIs in **onInit** and **onReady** when the page is still in the rendering phase.
## Module to Import<a name="s0e7b1e85a4274f58a8206e0b065bd80c"></a>
<td class="cellrowborder" valign="top" width="73.74000000000001%" headers="mcps1.1.5.1.4 "><p id="a7c61031878fe4accae87a2f6c74b3b89"><a name="a7c61031878fe4accae87a2f6c74b3b89"></a><a name="a7c61031878fe4accae87a2f6c74b3b89"></a>URI of the destination page, in either of the following formats:</p>
<a name="ul1495111211908"></a><a name="ul1495111211908"></a><ul id="ul1495111211908"><li>Absolute path of the page. The value is available in the <strong id="b13087524598"><a name="b13087524598"></a><a name="b13087524598"></a>pages</strong> list in the <strong id="b1031317527590"><a name="b1031317527590"></a><a name="b1031317527590"></a>config.json</strong> file, for example:<a name="ul067818331541"></a><a name="ul067818331541"></a><ul id="ul067818331541"><li>pages/index/index</li><li>pages/detail/detail</li></ul>
</li><li>Particular path. If the URI is a slash (/), the home page is displayed.</li></ul>
<td class="cellrowborder" valign="top" width="73.74000000000001%" headers="mcps1.1.5.1.4 "><p id="p13268162222310"><a name="p13268162222310"></a><a name="p13268162222310"></a>Data that needs to be passed to the destination page during navigation. After the destination page is displayed, it can use the passed data, for example, <strong id="b450711129286"><a name="b450711129286"></a><a name="b450711129286"></a>this.data1</strong> (<strong id="b105111112132816"><a name="b105111112132816"></a><a name="b105111112132816"></a>data1</strong> is a key in <strong id="b951212125286"><a name="b951212125286"></a><a name="b951212125286"></a>params</strong>). If there is the same key (for example, <strong id="b4486173192819"><a name="b4486173192819"></a><a name="b4486173192819"></a>data1</strong>) on the destination page, the passed <strong id="b148711382820"><a name="b148711382820"></a><a name="b148711382820"></a>data1</strong> value will overwrite the original value on the destination page.</p>
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.1.5.1.4 "><p id="ae5f1acce286d407896f0da896d170c60"><a name="ae5f1acce286d407896f0da896d170c60"></a><a name="ae5f1acce286d407896f0da896d170c60"></a>URI of the destination page, in either of the following formats:</p>
<a name="ul15140171014517"></a><a name="ul15140171014517"></a><ul id="ul15140171014517"><li>Absolute path of the page. The value is available in the <strong id="b20876747250"><a name="b20876747250"></a><a name="b20876747250"></a>pages</strong> list in the <strong id="b78818471951"><a name="b78818471951"></a><a name="b78818471951"></a>config.json</strong> file, for example:<a name="ul15140810655"></a><a name="ul15140810655"></a><ul id="ul15140810655"><li>pages/index/index</li><li>pages/detail/detail</li></ul>
</li><li>Particular path. If the URI is a slash (/), the home page is displayed.</li></ul>
<td class="cellrowborder" valign="top" width="72%" headers="mcps1.1.5.1.4 "><p id="p2143918144613"><a name="p2143918144613"></a><a name="p2143918144613"></a>Data that needs to be passed to the destination page during navigation. After the destination page is displayed, it can use the passed data, for example, <strong id="b2097028603"><a name="b2097028603"></a><a name="b2097028603"></a>this.data1</strong> (<strong id="b131829408"><a name="b131829408"></a><a name="b131829408"></a>data1</strong> is a key in <strong id="b1480025986"><a name="b1480025986"></a><a name="b1480025986"></a>params</strong>). If there is the same key (for example, <strong id="b1750090512"><a name="b1750090512"></a><a name="b1750090512"></a>data1</strong>) on the destination page, the passed <strong id="b1441904809"><a name="b1441904809"></a><a name="b1441904809"></a>data1</strong> value will overwrite the original value on the destination page.</p>
<td class="cellrowborder" valign="top" width="25%" headers="mcps1.1.5.1.4 "><p id="adf355f87a6e545a3b5cdcd5e78fcd8b3"><a name="adf355f87a6e545a3b5cdcd5e78fcd8b3"></a><a name="adf355f87a6e545a3b5cdcd5e78fcd8b3"></a>URI of the page to return to. If the specified page does not exist in the page stack, the app does not respond. If this parameter is not set, the app returns to the previous page.</p>
</td>
</tr>
</tbody>
</table>
- Example
```
// index page
export default {
indexPushPage() {
router.push({
uri: 'pages/detail/detail',
});
}
}
// detail page
export default {
detailPushPage() {
router.push({
uri: 'pages/mall/mall',
});
}
}
// Navigate from the mall page to the detail page through router.back().
export default {
mallBackPage() {
router.back();
}
}
// Navigate from the detail page to the index page through router.back().
export default {
defaultBack() {
router.back();
}
}
// Return to the detail page through router.back().
<td class="cellrowborder" valign="top" width="87.08%" headers="mcps1.1.3.1.2 "><p id="affc1140bcdf940de8705c921ccd68da5"><a name="affc1140bcdf940de8705c921ccd68da5"></a><a name="affc1140bcdf940de8705c921ccd68da5"></a>Number of pages in the stack. The maximum value is <strong id="b15825419161611"><a name="b15825419161611"></a><a name="b15825419161611"></a>32</strong>.</p>
<td class="cellrowborder" valign="top" width="78%" headers="mcps1.2.4.1.3 "><p id="p1979431135"><a name="p1979431135"></a><a name="p1979431135"></a>Index of the current page in the stack.</p>
<div class="note" id="note136715361314"><a name="note136715361314"></a><a name="note136715361314"></a><span class="notetitle"> NOTE: </span><div class="notebody"><p id="p1167137132"><a name="p1167137132"></a><a name="p1167137132"></a>The index starts from 1 from the bottom to the top of the stack.</p>
<td class="cellrowborder" valign="top" width="78%" headers="mcps1.2.4.1.3 "><p id="acf2d1680871b4630b121fc51835d5144"><a name="acf2d1680871b4630b121fc51835d5144"></a><a name="acf2d1680871b4630b121fc51835d5144"></a>Name of the current page, that is, the file name.</p>
<td class="cellrowborder" valign="top" width="78%" headers="mcps1.2.4.1.3 "><p id="a8f4870ec81224a75b82268b19b7c76de"><a name="a8f4870ec81224a75b82268b19b7c76de"></a><a name="a8f4870ec81224a75b82268b19b7c76de"></a>Path of the current page.</p>
<td class="cellrowborder" valign="top" width="52.88%" headers="mcps1.1.5.1.4 "><p id="p12138451192519"><a name="p12138451192519"></a><a name="p12138451192519"></a>Called when the operation is successful.</p>
<td class="cellrowborder" valign="top" width="52.88%" headers="mcps1.1.5.1.4 "><p id="p15586191613271"><a name="p15586191613271"></a><a name="p15586191613271"></a>Called when the operation is complete.</p>
<td class="cellrowborder" valign="top" width="53.11%" headers="mcps1.1.5.1.4 "><p id="p086920362331"><a name="p086920362331"></a><a name="p086920362331"></a>Called when the operation is successful.</p>
<td class="cellrowborder" valign="top" width="53.11%" headers="mcps1.1.5.1.4 "><p id="p20869203616332"><a name="p20869203616332"></a><a name="p20869203616332"></a>Called when the operation is complete.</p>
> The initial APIs of this module are supported since API 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides APIs related to **ServiceExtension**.
Provides APIs related to **ServiceExtension**.
...
@@ -10,13 +10,13 @@ Provides APIs related to **ServiceExtension**.
...
@@ -10,13 +10,13 @@ Provides APIs related to **ServiceExtension**.
## Modules to Import
## Modules to Import
```
```
import ServiceExtension from '@ohos.application.ServiceExtension';
import ServiceExtension from '@ohos.application.ServiceExtensionAbility';
```
```
## Required Permissions
## Required Permissions
None
None.
## Attributes
## Attributes
...
@@ -26,7 +26,7 @@ None
...
@@ -26,7 +26,7 @@ None
| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
| context | [ServiceExtensionContext](js-apis-service-extension-context.md) | Yes| No| Service extension context, which is inherited from **ExtensionContext**.<br>**System capability**: SystemCapability.Ability.AbilityRuntime.Core|
## onCreate
## ServiceExtensionAbility.onCreate
onCreate(want: Want): void;
onCreate(want: Want): void;
...
@@ -51,7 +51,7 @@ Called when an extension is created to initialize the service logic.
...
@@ -51,7 +51,7 @@ Called when an extension is created to initialize the service logic.
```
```
## onDestroy
## ServiceExtensionAbility.onDestroy
onDestroy(): void;
onDestroy(): void;
...
@@ -70,7 +70,7 @@ Called when this extension is destroyed to clear resources.
...
@@ -70,7 +70,7 @@ Called when this extension is destroyed to clear resources.
```
```
## onRequest
## ServiceExtensionAbility.onRequest
onRequest(want: Want, startId: number): void;
onRequest(want: Want, startId: number): void;
...
@@ -96,7 +96,7 @@ Called after **onCreate** is invoked when an ability is started by calling **sta
...
@@ -96,7 +96,7 @@ Called after **onCreate** is invoked when an ability is started by calling **sta
```
```
## onConnect
## ServiceExtensionAbility.onConnect
onConnect(want: Want): rpc.RemoteObject;
onConnect(want: Want): rpc.RemoteObject;
...
@@ -136,7 +136,7 @@ Called after **onCreate** is invoked when an ability is started by calling **con
...
@@ -136,7 +136,7 @@ Called after **onCreate** is invoked when an ability is started by calling **con
>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| ONE_TIME_FLAG | WantAgentFlags | The **WantAgent** object can be used only once. |
| NO_BUILD_FLAG | WantAgentFlags | The **WantAgent** object does not exist and hence it is not created. In this case, **null** is returned. |
| CANCEL_PRESENT_FLAG | WantAgentFlags | The existing **WantAgent** object should be canceled before a new object is generated.|
| UPDATE_PRESENT_FLAG | WantAgentFlags | Extra information of the existing **WantAgent** object is replaced with that of the new object.|
| CONSTANT_FLAG | WantAgentFlags | The **WantAgent** object is immutable. |
| REPLACE_ELEMENT | WantAgentFlags | The **element** attribute of the current **Want** can be replaced by the **element** attribute of the **Want** in **WantAgent.trigger()**.|
| REPLACE_ACTION | WantAgentFlags | The **action** attribute of the current **Want** can be replaced by the **action** attribute of the **Want** in **WantAgent.trigger()**.|
| REPLACE_URI | WantAgentFlags | The **uri** attribute of the current **Want** can be replaced by the **uri** attribute of the **Want** in **WantAgent.trigger()**.|
| REPLACE_ENTITIES | WantAgentFlags | The **entities** attribute of the current **Want** can be replaced by the **entities** attribute of the **Want** in **WantAgent.trigger()**.|
| REPLACE_BUNDLE | WantAgentFlags | The **bundleName** attribute of the current **Want** can be replaced by the **bundleName** attribute of **Want** in **WantAgent.trigger()**.|