| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| AppScope/ | 06-May-2025 | - | 35 | 32 | ||
| entry/ | 06-May-2025 | - | 626 | 482 | ||
| hvigor/ | 06-May-2025 | - | 24 | 22 | ||
| screenshots/zh/ | 06-May-2025 | - | ||||
| .gitignore | D | 06-May-2025 | 119 | 11 | 11 | |
| README_zh.md | D | 06-May-2025 | 4.4 KiB | 80 | 52 | |
| build-profile.json5 | D | 06-May-2025 | 1.1 KiB | 42 | 41 | |
| hvigorfile.ts | D | 06-May-2025 | 769 | 17 | 1 | |
| hvigorw | D | 06-May-2025 | 2.1 KiB | 62 | 28 | |
| hvigorw.bat | D | 06-May-2025 | 2 KiB | 73 | 56 | |
| oh-package.json5 | D | 06-May-2025 | 872 | 28 | 26 |
README_zh.md
1# 跨任务链返回(仅对系统应用开放) 2 3### 介绍 4 5本示例为一个仿桌面应用测试demo,使用[@ohos.app.ability.ServiceExtensionAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.ServiceExtensionAbility.d.ts)接口中ServiceExtensionContext类的startRecentAbility能力(系统能力:SystemCapability.Ability.AbilityRuntime.Core),实现了跨任务链返回的功能。 6 7### 效果预览 8 9| EntryAbility | SecondAbility | 10| --------------------------------------------------- | ----------------------------------------------------- | 11|  |  | 12 13使用说明 14 151.基于CrossChainBack工程(com.acts.abilityabacktoabilityb),对该工程编译产生的hap包进行手动签名。(仅CrossChainBack工程可实现跨任务链返回功能)。 16 172.安装签名成功后的hap包,启动仿桌面(Launcher)。 18 193.点击应用主界面上的应用图标,可以启动应用。 20 214.长按应用图标弹出菜单,点击打开,可以正常启动应用。 22 235.本应用包含:EntryAbility页面(页面中显示有"EntryAbility"文本)和SecondAbility页面(页面中显示有"SecondAbility"文本)。 24 256.在EntryAbility页面上点击StartSecondAbility按钮,打开SecondAbility,此时点击返回键,回到EntryAbility页面而不是桌面。 26 27 28### 工程目录 29 30``` 31entry/src/main/ets/ 32|---entryability 33| |---EntryAbility.ts 34|---logger 35| |---Logger.ts 36|---pages 37| |---Index.ets // EntryAbilit页面 38| |---IndexSecond.ets // SecondAbility页面 39|---secondability 40| |---SecondAbility.ts 41|---serviceability 42| |---ServiceAbility.ts // 后台拉起SecondAbility 43``` 44 45### 具体实现 46 47- 拉起任务至前台显示的功能接口封装在LauncherAbilityManager,源码参考:[LauncherAbilityManager.ts](../../../Launcher/base/src/main/ets/default/manager/LauncherAbilityManager.ts)。 48 - 跨任务链返回:在ServiceExtensionAbility,使用ServiceExtensionContext.startRecentAbility(),将Want中将"ABILITY_BACK_TO_OTHER_MISSION_STACK"(返回当前任务链字段)设置为"true",以实现返回至打开ServiceExtensionAbility的ability的功能。 49 - 接口参考:[@ohos.app.ability.wantConstant](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.wantConstant.d.ts)、[@ohos.app.ability.ServiceExtensionAbility](https://gitee.com/openharmony/interface_sdk-js/blob/master/api/@ohos.app.ability.ServiceExtensionAbility.d.ts) 50 51### 相关权限 52 53[ohos.permission.START_ABILITIES_FROM_BACKGROUND](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md#ohospermissionstart_abilities_from_background) 54 55### 依赖 56 57本测试demo需要安装在仿桌面应用上进行测试。launcher应用地址:[Launcher](../../../Launcher/) 58 59### 约束与限制 60 611.本示例仅支持标准系统上运行,支持设备:RK3568。 62 632.本示例已适配API version 9版本SDK,版本号:3.2.11.9。 64 653.本示例需要使用DevEco Studio 3.1 Beta2 (Build Version: 3.1.0.400 构建 2023年4月7日)才可编译运行。 66 674.本示例使用了ServiceExtensionAbility,需要在签名证书UnsgnedReleasedProfileTemplate.json中配置"app-privilege-capabilities": ["AllowAppUsePrivilegeExtension"],否则安装失败。具体操作指南可参考[应用特权配置指南](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/subsystems/subsys-app-privilege-config-guide.md)。 68 695.本示例所配置的权限为system_basic级别(相关权限级别可通过[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-system-apps.md)查看),需要手动配置对应级别的权限签名(具体操作可查看[自动化签名方案](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/hapsigntool-overview.md))。 70 71### 下载 72 73如需单独下载本工程,执行如下命令: 74``` 75git init 76git config core.sparsecheckout true 77echo code/SystemFeature/ApplicationModels/TestRely/LauncherTest/CrossChainBack/ > .git/info/sparse-checkout 78git remote add origin https://gitee.com/openharmony/applications_app_samples.git 79git pull origin master 80```