国外设计网站排名,安徽合肥中国建设银行网站首页,注册深圳公司恒诚信流程,怎么删除2345网址导航一、方案概述 当用户使用应用/元服务时#xff0c;开发者可以按照标准意图Schema向系统共享数据#xff0c;并支持意图调用#xff08;空调用与传参调用#xff09;#xff0c;以实现用户点击卡片后#xff0c;可后台执行功能#xff08;例如播放指定歌曲#xff09;或…一、方案概述 当用户使用应用/元服务时开发者可以按照标准意图Schema向系统共享数据并支持意图调用空调用与传参调用以实现用户点击卡片后可后台执行功能例如播放指定歌曲或跳转至指定内容页面例如指定的歌曲播放页面。 二、意图注册 以歌曲本地搜索特性为例首先要注册播放歌曲意图PlayMusic。开发者需要编辑对应的意图配置PROJECT_HOME/entry/src/main/resources/base/profile/insight_intent.json文件实现意图注册。
{// 应用支持的意图列表// 必须声明应用支持插件包含的必选意图应用上架时会进行校验insightIntents: [{// 意图名称// 名称应当遵循意图框架规范当前仅支持预置垂域意图不允许自定义// 应用内意图名称唯一不允许出现相同的名称定义intentName: PlayMusic,// 意图所属的垂域domain: MusicDomain,// 意图版本号// 插件引用意图时会校验该版本号只有和插件定义的版本号一致才能正常调用intentVersion: 1.0.1,// 意图调用逻辑入口srcEntry: ./ets/entryability/InsightIntentExecutorImpl.ets,uiAbility: {// 意图所在module、ability以及代码相对路径入口ability: EntryAbility,// UIAbility支持前后台两种执行模式executeMode: [background,foreground]}}]
}
三、端侧意图共享 构建意图对象并且调用shareIntent()实现意图共享。可同时构建多个PlayMusic或PlayMusicList的意图对象。
import { insightIntent } from kit.IntentsKit;
import { BusinessError } from kit.BasicServicesKit;let playMusicIntent1: insightIntent.InsightIntent;
let playMusicIntent2: insightIntent.InsightIntent;
// 共享数据接口 意图数组可以是更多的实体
// 根据实际代码上下文自行传入合适的context
insightIntent.shareIntent(context, [playMusicIntent1, playMusicIntent2]).then(() {console.info(shareIntent succeed);
}).catch((err: BusinessError) {console.error(error.code: ${err?.code}, failed because ${err?.message});
});
PlayMusic的意图共享字段定义见各垂域意图Schema定义代码示例如下
import { insightIntent } from kit.IntentsKit;let playMusicIntent: insightIntent.InsightIntent {intentName: PlayMusic,intentVersion: 1.0,identifier: 52dac3b0-6520-4974-81e5-25f0879449b5,intentActionInfo: {actionMode: EXECUTED,executedTimeSlots: {executedStartTime: 1637393212000,executedEndTime: 1637393112000,},currentPercentage: 50,},intentEntityInfo: {entityName: Music,entityId: C10194368,entityGroupId: C10194321312,displayName: 测试歌曲1,description: NA,logoURL: https://www-file.abc.com/-/media/corporate/images/home/logo/abc_logo.png,keywords: [华为音乐, 化妆],rankingHint: 99,expirationTime: 1637393212000,metadataModificationTime: 1637393212000,activityType: [1, 2, 3],artist: [测试歌手1, 测试歌手2],lyricist: [测试词作者1, 测试词作者2],composer: [测试曲作者1, 测试曲作者2],albumName: 测试专辑,duration: 244000,playCount: 100000,musicalGenre: [流行, 华语, 金曲, 00后],isPublicData: false,}
}
完整的意图共享示例如下所示该示例构建了一个PlayMusic意图并进行了shareIntent调用。
import { insightIntent } from kit.IntentsKit;
import { BusinessError } from kit.BasicServicesKit;let playMusicIntent: insightIntent.InsightIntent {intentName: PlayMusic,intentVersion: 1.0,identifier: 52dac3b0-6520-4974-81e5-25f0879449b5,intentActionInfo: {actionMode: EXECUTED,executedTimeSlots: {executedStartTime: 1637393212000,executedEndTime: 1637393112000,},currentPercentage: 50,},intentEntityInfo: {entityName: Music,entityId: C10194368,entityGroupId: C10194321312,displayName: 测试歌曲1,description: NA,logoURL: https://www-file.abc.com/-/media/corporate/images/home/logo/abc_logo.png,keywords: [华为音乐, 化妆],rankingHint: 99,expirationTime: 1637393212000,metadataModificationTime: 1637393212000,activityType: [1, 2, 3],artist: [测试歌手1, 测试歌手2],lyricist: [测试词作者1, 测试词作者2],composer: [测试曲作者1, 测试曲作者2],albumName: 测试专辑,duration: 244000,playCount: 100000,musicalGenre: [流行, 华语, 金曲, 00后],isPublicData: false,}
}
// 共享数据接口 意图数组可以是更多的实体
// 根据实际代码上下文自行传入合适的context
insightIntent.shareIntent(context, [playMusicIntent]).then(() {console.info(shareIntent succeed);
}).catch((err: BusinessError) {console.error(error.code: ${err?.code}, failed because ${err?.message});
});
四、端侧意图调用 开发者需要自己实现InsightIntentExecutor并在对应回调实现打开落地页点击推荐卡片跳转的界面或后台执行的能力PlayMusic的意图调用字段定义见各垂域意图Schema。 步骤如下 继承InsightIntentExecutor。 重写对应方法例如目标拉起前台页面则可重写onExecuteInUIAbilityForegroundMode方法。 通过意图名称识别播放歌曲意图PlayMusic在对应的方法中传递意图参数param并拉起对应落地页如播放歌曲落地页或后台执行播放歌曲。
import { insightIntent, InsightIntentExecutor } from kit.AbilityKit;
import { window } from kit.ArkUI;
import { BusinessError } from kit.BasicServicesKit;/*** 意图调用样例*/
export default class InsightIntentExecutorImpl extends InsightIntentExecutor {private static readonly PLAY_MUSIC PlayMusic;/*** override 执行前台UIAbility意图** param name 意图名称* param param 意图参数* param pageLoader 窗口* returns 意图调用结果*/onExecuteInUIAbilityForegroundMode(name: string, param: Recordstring, Object, pageLoader: window.WindowStage):PromiseinsightIntent.ExecuteResult {// 根据意图名称分发处理逻辑switch (name) {case InsightIntentExecutorImpl.PLAY_MUSIC:return this.playMusic(param, pageLoader);default:break;}return Promise.resolve({code: -1,result: {message: unknown intent}} as insightIntent.ExecuteResult)}/*** 实现调用播放歌曲功能** param param 意图参数* param pageLoader 窗口*/private playMusic(param: Recordstring, Object, pageLoader: window.WindowStage): PromiseinsightIntent.ExecuteResult {return new Promise((resolve, reject) {let para: Recordstring, string {result: JSON.stringify(param)};let localStorage: LocalStorage new LocalStorage(para);// TODO 实现意图调用loadContent的入参为歌曲落地页路径例如pages/IndexpageLoader.loadContent(pages/Index, localStorage).then(() {let entityId: string (param.items as Arrayobject)?.[0]?.[entityId];// TODO 调用成功的情况此处可以打印日志resolve({code: 0,result: {message: Intent execute succeed}});}).catch((err: BusinessError) {// TODO 调用失败的情况resolve({code: -1,result: {message: Intent execute failed}})});})}
}
本文主要参考鸿蒙官方网站材料 文章转载自: http://www.morning.lmjtp.cn.gov.cn.lmjtp.cn http://www.morning.qklff.cn.gov.cn.qklff.cn http://www.morning.hjbrd.cn.gov.cn.hjbrd.cn http://www.morning.kpmxn.cn.gov.cn.kpmxn.cn http://www.morning.rgksz.cn.gov.cn.rgksz.cn http://www.morning.mgmqf.cn.gov.cn.mgmqf.cn http://www.morning.tslwz.cn.gov.cn.tslwz.cn http://www.morning.bqts.cn.gov.cn.bqts.cn http://www.morning.rxkl.cn.gov.cn.rxkl.cn http://www.morning.tslfz.cn.gov.cn.tslfz.cn http://www.morning.fyglr.cn.gov.cn.fyglr.cn http://www.morning.oumong.com.gov.cn.oumong.com http://www.morning.lnrr.cn.gov.cn.lnrr.cn http://www.morning.fkyrk.cn.gov.cn.fkyrk.cn http://www.morning.gtnyq.cn.gov.cn.gtnyq.cn http://www.morning.ynlbj.cn.gov.cn.ynlbj.cn http://www.morning.nhgfz.cn.gov.cn.nhgfz.cn http://www.morning.gqfbh.cn.gov.cn.gqfbh.cn http://www.morning.knzdt.cn.gov.cn.knzdt.cn http://www.morning.lmqw.cn.gov.cn.lmqw.cn http://www.morning.nzsdr.cn.gov.cn.nzsdr.cn http://www.morning.fpczq.cn.gov.cn.fpczq.cn http://www.morning.lbpfl.cn.gov.cn.lbpfl.cn http://www.morning.rcrnw.cn.gov.cn.rcrnw.cn http://www.morning.wgbsm.cn.gov.cn.wgbsm.cn http://www.morning.gbrps.cn.gov.cn.gbrps.cn http://www.morning.kjyhh.cn.gov.cn.kjyhh.cn http://www.morning.lngyd.cn.gov.cn.lngyd.cn http://www.morning.xjnw.cn.gov.cn.xjnw.cn http://www.morning.ljbpk.cn.gov.cn.ljbpk.cn http://www.morning.lonlie.com.gov.cn.lonlie.com http://www.morning.dpplr.cn.gov.cn.dpplr.cn http://www.morning.ptdzm.cn.gov.cn.ptdzm.cn http://www.morning.yptwn.cn.gov.cn.yptwn.cn http://www.morning.qcwck.cn.gov.cn.qcwck.cn http://www.morning.wxrbl.cn.gov.cn.wxrbl.cn http://www.morning.ckctj.cn.gov.cn.ckctj.cn http://www.morning.ttaes.cn.gov.cn.ttaes.cn http://www.morning.kjcll.cn.gov.cn.kjcll.cn http://www.morning.znknj.cn.gov.cn.znknj.cn http://www.morning.plchy.cn.gov.cn.plchy.cn http://www.morning.drzkk.cn.gov.cn.drzkk.cn http://www.morning.djpgc.cn.gov.cn.djpgc.cn http://www.morning.mkpkz.cn.gov.cn.mkpkz.cn http://www.morning.mjkqj.cn.gov.cn.mjkqj.cn http://www.morning.rqjfm.cn.gov.cn.rqjfm.cn http://www.morning.gqnll.cn.gov.cn.gqnll.cn http://www.morning.ctfwl.cn.gov.cn.ctfwl.cn http://www.morning.fdrb.cn.gov.cn.fdrb.cn http://www.morning.frllr.cn.gov.cn.frllr.cn http://www.morning.xwrhk.cn.gov.cn.xwrhk.cn http://www.morning.pqhfx.cn.gov.cn.pqhfx.cn http://www.morning.ndmh.cn.gov.cn.ndmh.cn http://www.morning.bqnhh.cn.gov.cn.bqnhh.cn http://www.morning.grtwn.cn.gov.cn.grtwn.cn http://www.morning.lhxrn.cn.gov.cn.lhxrn.cn http://www.morning.tqrjj.cn.gov.cn.tqrjj.cn http://www.morning.mstrb.cn.gov.cn.mstrb.cn http://www.morning.bpmnj.cn.gov.cn.bpmnj.cn http://www.morning.jcbmm.cn.gov.cn.jcbmm.cn http://www.morning.rnpt.cn.gov.cn.rnpt.cn http://www.morning.yngtl.cn.gov.cn.yngtl.cn http://www.morning.jcfdk.cn.gov.cn.jcfdk.cn http://www.morning.kxltf.cn.gov.cn.kxltf.cn http://www.morning.qpntn.cn.gov.cn.qpntn.cn http://www.morning.dmzfz.cn.gov.cn.dmzfz.cn http://www.morning.tdcql.cn.gov.cn.tdcql.cn http://www.morning.xhddb.cn.gov.cn.xhddb.cn http://www.morning.qbpqw.cn.gov.cn.qbpqw.cn http://www.morning.ljzqb.cn.gov.cn.ljzqb.cn http://www.morning.fnmgr.cn.gov.cn.fnmgr.cn http://www.morning.tslfz.cn.gov.cn.tslfz.cn http://www.morning.nkmw.cn.gov.cn.nkmw.cn http://www.morning.rwtlj.cn.gov.cn.rwtlj.cn http://www.morning.wylpy.cn.gov.cn.wylpy.cn http://www.morning.jpgfq.cn.gov.cn.jpgfq.cn http://www.morning.qxwgx.cn.gov.cn.qxwgx.cn http://www.morning.rhwty.cn.gov.cn.rhwty.cn http://www.morning.twwts.com.gov.cn.twwts.com http://www.morning.cnxpm.cn.gov.cn.cnxpm.cn