当前位置: 首页 > news >正文

2018做网站哪里可以做寄生虫网站

2018做网站,哪里可以做寄生虫网站,人才招聘网官网入口,苏州本地网站文章目录一、背景二、app发起分享1. 通过分享面板进行分享2. 使用其他应用打开二、处理分享的内容1. module.json5 配置可接收分享2. 解析分享的数据一、背景 在App开发中,分享是常用功能,这里介绍鸿蒙开发中,其他应用分享到自己的app中&…

文章目录

  • 一、背景
  • 二、app发起分享
    • 1. 通过分享面板进行分享
    • 2. 使用其他应用打开
  • 二、处理分享的内容
    • 1. `module.json5` 配置可接收分享
    • 2. 解析分享的数据

一、背景

在App开发中,分享是常用功能,这里介绍鸿蒙开发中,其他应用分享到自己的app中,或者自己的app分享给其他app
鸿蒙系统分享地址

二、app发起分享

1. 通过分享面板进行分享

  1. 导入相关模块。
import { common } from '@kit.AbilityKit';
import { systemShare } from '@kit.ShareKit';
import { uniformTypeDescriptor as utd } from '@kit.ArkData';
  1. 获取统一数据类型
    可以自己确定分享的类型,也可以调用方法通过后缀获取分享类型
    getUniformDataTypeByFilenameExtension
let utdTypeId = ""if (file.extension.length == 0) {utdTypeId = utd.UniformDataType.FOLDER} else {utdTypeId = utd.getUniformDataTypeByFilenameExtension(file.extension, utd.UniformDataType.OBJECT);}if (utdTypeId.length == 0) {promptAction.showToast({message: appUtils.getResString('share_tip2')})return}
  1. 构造分享数据,可添加多条分享记录。
let shareData: systemShare.SharedData = new systemShare.SharedData({utd: utdTypeId,uri: file.uri});
  1. 启动分享面板时,配置分享面板显示的位置信息或关联的组件ID,面板将以Popup形式展示。
let controller: systemShare.ShareController = new systemShare.ShareController(shareData);// 获取UIAbility上下文对象let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;// 进行分享面板显示controller.show(context, {previewMode: systemShare.SharePreviewMode.DEFAULT,selectionMode: systemShare.SelectionMode.SINGLE});

2. 使用其他应用打开

通过context调用startAbility,弹出系统弹窗,使用其他应用打开文件

// Construct request data Want, taking opening a Word file as an examplelet wantInfo: Want = {uri: file.uri, // Indicate the URI path of the file to be opened, usually used in conjunction with typetype: 'application/msword', // Indicate the type of file to be openedflags: wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION, // Authorization to perform write operations on URI}// Call the startAbility interface to open fileslet context = getContext(this) as common.UIAbilityContext;context.startAbility(wantInfo).then(() => {console.info("分享成功");}).catch((err: BusinessError) => {console.info("分享失败");})

二、处理分享的内容

1. module.json5 配置可接收分享

module.json5 下找到 abilities标签,找到 skills

  1. 配置entities添加 "entity.system.share"
"entities": ["entity.system.home","entity.system.share"],
  1. 配置actions,添加actions
"actions": ["action.system.home","ohos.want.action.select","ohos.want.action.sendData","ohos.want.action.viewData" // 必填,声明数据处理能力],
  1. 配置uris
"uris": [{"scheme": "file",// 物理存储类型的基类型"utd": "general.entity","maxFileSupported": 1,"linkFeature": "FileOpen"},{"scheme": "file",// 逻辑内容类型的基类型"utd": "general.object","maxFileSupported": 1,"linkFeature": "FileOpen"}]

2. 解析分享的数据

  1. 在其onCreate或onNewWant回调中获取传入的want参数
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);// 注入Ability上下文到AppUtilsAppUtils.getInstance().context = this.context;hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');ShareManager.getInstance().handelShareData(want);}
onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void {ShareManager.getInstance().handelShareData(want)}
  1. 通过getSharedData 解析分享数据
/** 处理分享过来的文件 */public handelShareData(want: Want) {systemShare.getSharedData(want).then((data: systemShare.SharedData) => {data.getRecords().forEach((record: systemShare.SharedRecord) => {// 处理分享数据});}).catch((error: BusinessError) => {DKLogger.error(`Failed to getSharedData. Code: ${error.code}, message: ${error.message}`);// this.context.terminateSelf();if (want.action == 'ohos.want.action.sendData'|| want.action == 'ohos.want.action.viewData') {}});}

处理完分享数据,即可将数据在页面显示

http://www.dtcms.com/a/481821.html

相关文章:

  • 腾讯云的游戏盾怎么样
  • C++函数完全指南:从基础到高级应用
  • 国自然申报·医工交叉热点|单细胞多模态融合破解病理研究痛点
  • html情人节给女朋友做网站WordPress在手机能更新
  • springboot餐厅信息管理系统设计(代码+数据库+LW)
  • Jenkins Share Library教程 —— 高级实战与最佳实践教程
  • Blender图片AI智能一键生成3D模型插件 Pixelmodeller Ai V1.4.9
  • CAA机器学习
  • LeetCode hot100:128 最长连续序列:高效求解
  • 上海网站制作 优化wordpress 去除google
  • [Backstage] 软件模板Scaffolder | 定义“Node.js微服务“
  • 链表操作教学工具
  • 珠海市网站建设的公司网站安全维护
  • PC端AI推理存储IO流量剖析
  • 如何在AutoCAD中管理GIS属性表?
  • 消防模块-图形识别快速匹配
  • 备案网站名怎么写前端微信小程序开发
  • 使用Spring Boot构建多维度配置层
  • vps 可以做多个网站吗沈阳营销网站建设
  • 上传文件相关业务,采用策略模式+模版方法模式进行动态解耦
  • Unity3d中Tab控件的实现
  • 桥梁主动防撞预警系统方案
  • 【node】运行windows7下的高版本node.js
  • 解密NLP:从入门到精通
  • 如何说课网站建设当地公交建设公司的官网
  • 哪里有网站开发服务器西安关键词排名提升
  • npx 与 npm 区别
  • diffusion model(0.5) score-SDE 关于score function与noise的关系
  • leetcode724 寻找数组的中心下标
  • AI用户洞察新纪元:atypica.AI如何重塑商业决策逻辑