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

!4957 onNewWant相关的资料修改

Merge pull request !4957 from 张亚菲/zyf
......@@ -50,7 +50,7 @@ Ability功能如下(Ability类,具体的API详见[接口文档](../reference
|onWindowStageDestroy(): void|Ability生命周期回调,销毁window stage时被调用。|
|onForeground(): void|Ability生命周期回调,Ability切换至前台时被调用。|
|onBackground(): void|Ability生命周期回调,Ability切换至后台时被调用。|
|onNewWant(want: Want): void|Ability回调,Ability的启动模式设置为单例时被调用。|
|onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void|Ability回调,Ability的启动模式设置为单例时被调用。|
|onConfigurationUpdated(config: Configuration): void|Ability回调,Ability的系统配置更新时被调用。|
### 实现AbilityStage及Ability生命周期
创建Stage模型的Page Ability应用,需实现AbilityStage接口及Ability生命周期接口,并使用窗口提供的方法设置页面。具体示例代码如下:
......@@ -292,7 +292,7 @@ async function reStartAbility() {
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onNewWant(want) {
onNewWant(want, launchParams) {
globalThis.newWant = want
}
}
......
......@@ -210,7 +210,7 @@ onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult;
## Ability.onNewWant
onNewWant(want: Want): void;
onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
当ability的启动模式设置为单例时回调会被调用。
......@@ -221,13 +221,17 @@ onNewWant(want: Want): void;
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| want | [Want](js-apis-application-Want.md) | 是 | Want类型参数,如ability名称,包名等。 |
| launchParams | AbilityConstant.LaunchParam | 是 | Ability启动的原因、上次异常退出的原因信息。 |
**示例:**
```js
class myAbility extends Ability {
onNewWant(want) {
onNewWant(want, launchParams) {
console.log('onNewWant, want:' + want.abilityName);
if (launchParams.launchReason === AbilityConstant.LaunchReason.CONTINUATION) {
console.log('onNewWant, launchReason is continuation');
}
}
}
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册