harmony 鸿蒙@ohos.bundle.shortcutManager (shortcutManager模块)
@ohos.bundle.shortcutManager (shortcutManager模块)
本模块提供应用对于快捷方式管理能力,包括设置快捷方式是否显示等。
说明:
本模块首批接口从API version 20开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
导入模块
import { shortcutManager } from '@kit.AbilityKit';
shortcutManager.setShortcutVisibleForSelf
setShortcutVisibleForSelf(id: string, visible: boolean) : Promise<void>
设置当前应用指定ID对应的快捷方式是否显示,使用Promise异步回调。
系统能力: SystemCapability.BundleManager.BundleFramework.Launcher
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
id | string | 是 | 快捷方式的ID,通过module.json5配置文件中的shortcuts标签下的shortcutId字段获取,取值为长度不超过63字节的字符串。 |
visible | boolean | 是 | 快捷方式是否显示。true:快捷方式显示;false:快捷方式不显示。 |
返回值:
类型 | 说明 |
---|---|
Promise<void> | Promise对象。无返回结果的Promise对象。 |
错误码:
以下错误码的详细介绍请参见包管理子系统通用错误码。
错误码ID | 错误信息 |
---|---|
17700070 | The specified shortcut id is illegal. |
示例:
import { shortcutManager } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
// 请替换为module.json5配置文件中的shortcuts标签下实际配置的shortcutId字段
shortcutManager.setShortcutVisibleForSelf("shortcut_id", false)
.then(() => {
console.info("setShortcutVisibleForSelf success");
}).catch((err: BusinessError) => {
console.error("setShortcutVisibleForSelf errData is errCode:${err.code} message:${err.message}");
});
shortcutManager.getAllShortcutInfoForSelf
getAllShortcutInfoForSelf(): Promise<Array<ShortcutInfo>>
查询当前应用配置文件中定义的所有快捷方式信息,使用Promise异步回调。
系统能力: SystemCapability.BundleManager.BundleFramework.Launcher
返回值:
类型 | 说明 |
---|---|
Promise |
Promise对象,返回应用配置文件中定义的所有快捷方式信息。 |
示例:
import { shortcutManager } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';
shortcutManager.getAllShortcutInfoForSelf()
.then((data: shortcutManager.ShortcutInfo[]) => {
console.info("getAllShortcutInfoForSelf shortcut data is" + JSON.stringify(data));
}).catch((err: BusinessError) => {
console.error("getAllShortcutInfoForSelf errData is errCode:${err.code} message:${err.message}");
});
你可能感兴趣的鸿蒙文章
harmony 鸿蒙OH_NativeBundle_ApplicationInfo
harmony 鸿蒙OH_NativeBundle_ElementName
harmony 鸿蒙ability_base_common.h
0
赞
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦