1 Star 0 Fork 5.4K

huangdong / docs_scroll_page_0305

forked from OpenHarmony / docs 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
js-apis-app-ability-startOptions.md 2.54 KB
一键复制 编辑 原始数据 按行查看 历史

@ohos.app.ability.StartOptions (StartOptions)

StartOptions is used as an input parameter of startAbility() to specify the window mode of an ability.

NOTE

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. The APIs of this module can be used only in the stage model.

Modules to Import

import StartOptions from '@ohos.app.ability.StartOptions';

Attributes

System capability: SystemCapability.Ability.AbilityRuntime.Core

Name Type Mandatory Description
windowMode number No Window mode.
System API: This is a system API and cannot be called by third-party applications.
displayId number No Display ID mode. The default value is 0, indicating the current display.
withAnimation11+ boolean No Whether the ability has the animation effect.
windowLeft11+ number No Left position of the window.
windowTop11+ number No Top position of the window.
windowWidth11+ number No Width of the window.
windowHeight11+ number No Height of the window.

Example

import UIAbility from '@ohos.app.ability.UIAbility';
import Want from '@ohos.app.ability.Want';
import StartOptions from '@ohos.app.ability.StartOptions';
import { BusinessError } from '@ohos.base';

export default class EntryAbility extends UIAbility {

  onForeground() {
    let want: Want = {
      deviceId: '',
      bundleName: 'com.example.myapplication',
      abilityName: 'EntryAbility'
    };
    let options: StartOptions = {
      windowMode: 0
    };

    try {
      this.context.startAbility(want, options, (err: BusinessError) => {
        if (err.code) {
          // Process service logic errors.
          console.error(`startAbility failed, code is ${err.code}, message is ${err.message}`);
          return;
        }
        // Carry out normal service processing.
        console.info('startAbility succeed');
      });
    } catch (err) {
      // Process input parameter errors.
      let code = (err as BusinessError).code;
      let message = (err as BusinessError).message;
      console.error(`startAbility failed, code is ${code}, message is ${message}`);
    }
  }
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
其他
1
https://gitee.com/huangdong2738/docs_scroll_page_0305.git
git@gitee.com:huangdong2738/docs_scroll_page_0305.git
huangdong2738
docs_scroll_page_0305
docs_scroll_page_0305
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891