harmony 鸿蒙@ohos.app.ability.AbilityConstant (AbilityConstant) (System API)

  • 2025-06-12
  • 浏览 (4)

@ohos.app.ability.AbilityConstant (AbilityConstant) (System API)

The AbilityConstant module defines the enums of the window types in the UIAbility.

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.

This topic describes only system APIs provided by the module. For details about its public APIs, see @ohos.app.ability.AbilityConstant (AbilityConstant).

Modules to Import

import { AbilityConstant } from '@kit.AbilityKit';

WindowMode12+

Enumerates the window modes in which an ability can be displayed at startup. It can be used in startAbility() to specify the window mode when the ability is started.

System capability: SystemCapability.Ability.AbilityRuntime.Core

System API: This is a system API.

Name Value Description
WINDOW_MODE_UNDEFINED 0 Undefined window mode.
WINDOW_MODE_FLOATING 102 The ability is displayed in a floating window.

Example

import { UIAbility, StartOptions, Want, AbilityConstant } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

let want: Want = {
  bundleName: 'com.example.myapplication',
  abilityName: 'EntryAbility'
};
let option: StartOptions = {
  windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FULLSCREEN
};

// Ensure that the context is obtained.
class MyAbility extends UIAbility {
  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
    this.context.startAbility(want, option).then(() => {
      console.log('Succeed to start ability.');
    }).catch((error: BusinessError) => {
      console.error('Failed to start ability with error: ${JSON.stringify(error)}');
    });
  }
}

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Ability Kit

harmony 鸿蒙AbilityAccessControl

harmony 鸿蒙AbilityBase

harmony 鸿蒙AbilityBase_Element

harmony 鸿蒙AbilityRuntime

harmony 鸿蒙bundle

harmony 鸿蒙OH_NativeBundle_ApplicationInfo

harmony 鸿蒙OH_NativeBundle_ElementName

harmony 鸿蒙ability_access_control.h

harmony 鸿蒙ability_base_common.h

0  赞