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

自由建网站的网络程序镇江关键字优化品牌

自由建网站的网络程序,镇江关键字优化品牌,钟表东莞网站建设,新乡做网站优化接上一篇:arkui-x跨平台与android java联合开发-CSDN博客 本篇讲前端arkui如何与后端其他平台进行数据交互,接上一篇,后端os平台为Android java。 arkui-x框架提供了一个独特的机制:bridge。 1、前端接口定义实现 定义一个bri…

接上一篇:arkui-x跨平台与android java联合开发-CSDN博客

本篇讲前端arkui如何与后端其他平台进行数据交互,接上一篇,后端os平台为Android java。

arkui-x框架提供了一个独特的机制:bridge。

1、前端接口定义实现

定义一个bridge的class,里面创建平台桥接实例,就可以实现各种bridge接口。

这里实现了一个getThirdAppInfo接口,获取后端第三方应用的信息。参数为两个string,返回一个promise数据。promise也就是JavaScript中用于处理异步操作的一种机制,详细说法这里就不展开了。

DevEco Studio工程

import bridge from '@arkui-x.bridge';export class ThirdPartyBridge {// 创建平台桥接实例private thirdPartyBridge = bridge?.createBridge && bridge.createBridge('xBridge');public getThirdAppInfo(defaultCfg: string, sysAppList: string) {return new Promise<string>((resolve, reject) => {this.thirdPartyBridge.callMethod('getThirdAppInfo', defaultCfg, sysAppList).then((result) => {console.log("getThirdAppInfo: ", result)resolve(result ? result.toString() : "")}).catch((err: Error) => {console.log('getThirdAppInfo err', JSON.stringify(err))})})}
}

2、后端数据获取接口

Android Studio工程

import ohos.ace.adapter.capability.bridge.BridgeManager;
import ohos.ace.adapter.capability.bridge.BridgePlugin;@SuppressLint("LogNotTimber")
public class Bridge extends BridgePlugin {private static final String TAG = Bridge.class.getSimpleName();public Bridge(Context context, String name, BridgeManager bridgeManager) {super(context, name, bridgeManager);}
。。。。。。public String getThirdAppInfo(String defaultCfg, String sysAppStr) throws JSONException {
//        Log.d("getThirdAppInfo", "---para1: " + defaultCfg + " para2: " + sysAppStr);List<JSONObject> retList = new ArrayList<>();
。。。。。。
// 实现获取数据的逻辑return retList.toString();}
。。。。。。
}

这里返回数据定义为json字符串,是为了方便前端解析。

3、前端调用bridge的业务代码实现

DevEco Studio工程

import { ThirdPartyBridge } from '../../bridge/ThirdPartyBridge';
import { DesktopShowCfg, ThirdPartyAppInfo } from '../../model/ThirdPartyAppInfo'export const getThirdAppInfo = async (defaultCfg: string, sysAppList: ThirdPartyAppInfo[]): Promise<ThirdPartyAppInfo[]> => {try {let sysAppStr: string = '[';
......// ThirdPartyAppInfo[]转为stringsysAppStr += ']'const bridge = new ThirdPartyBridge()const str = await bridge.getThirdAppInfo(defaultCfg, sysAppStr)console.log("---getThirdAppInfo", `获取第三方应用信息成功:` + str)let appInfoListList: ThirdPartyAppInfo[] = JSON.parse(str) as ThirdPartyAppInfo[]console.log("---getThirdAppInfo", `获取第三方应用信息,解析成功,app数量为:` + appInfoListList.length)return appInfoListList} catch (e) {console.log("---getThirdAppInfo", `获取第三方应用信息失败`, e.message)return []}
}

这里直接使用 JSON.parse(str) as ThirdPartyAppInfo[]方式实现了快速解析json。


文章转载自:
http://gynecomorphous.hwLk.cn
http://dight.hwLk.cn
http://euchromatin.hwLk.cn
http://bhikshu.hwLk.cn
http://bhakta.hwLk.cn
http://korfball.hwLk.cn
http://diphthongise.hwLk.cn
http://riverfront.hwLk.cn
http://tremissis.hwLk.cn
http://landlocked.hwLk.cn
http://pali.hwLk.cn
http://nitrochalk.hwLk.cn
http://neighbourship.hwLk.cn
http://redundancy.hwLk.cn
http://ninja.hwLk.cn
http://fraktur.hwLk.cn
http://mouseproof.hwLk.cn
http://tinning.hwLk.cn
http://num.hwLk.cn
http://circunglibal.hwLk.cn
http://strati.hwLk.cn
http://protrusile.hwLk.cn
http://lengthwise.hwLk.cn
http://symphony.hwLk.cn
http://procambium.hwLk.cn
http://mawlamyine.hwLk.cn
http://unipole.hwLk.cn
http://excentric.hwLk.cn
http://bantam.hwLk.cn
http://crick.hwLk.cn
http://caseate.hwLk.cn
http://sufferable.hwLk.cn
http://buccinator.hwLk.cn
http://escribe.hwLk.cn
http://unstring.hwLk.cn
http://cerated.hwLk.cn
http://reppo.hwLk.cn
http://lipogenesis.hwLk.cn
http://thrace.hwLk.cn
http://bucktail.hwLk.cn
http://chthonic.hwLk.cn
http://sputa.hwLk.cn
http://hibachi.hwLk.cn
http://paleolithic.hwLk.cn
http://vavasour.hwLk.cn
http://anorexia.hwLk.cn
http://illawarra.hwLk.cn
http://nigrify.hwLk.cn
http://shenzhen.hwLk.cn
http://commonalty.hwLk.cn
http://gawkish.hwLk.cn
http://keybugle.hwLk.cn
http://adagiettos.hwLk.cn
http://cosie.hwLk.cn
http://weighman.hwLk.cn
http://tinder.hwLk.cn
http://lcd.hwLk.cn
http://buckshee.hwLk.cn
http://queuer.hwLk.cn
http://regalism.hwLk.cn
http://elimination.hwLk.cn
http://alsike.hwLk.cn
http://noises.hwLk.cn
http://stagflationary.hwLk.cn
http://clown.hwLk.cn
http://commoner.hwLk.cn
http://cameral.hwLk.cn
http://morigeration.hwLk.cn
http://snotnose.hwLk.cn
http://illegitimate.hwLk.cn
http://culturable.hwLk.cn
http://bound.hwLk.cn
http://cuspidated.hwLk.cn
http://kharakteristika.hwLk.cn
http://sakkara.hwLk.cn
http://morena.hwLk.cn
http://somite.hwLk.cn
http://expostulator.hwLk.cn
http://suez.hwLk.cn
http://intertranslatable.hwLk.cn
http://idg.hwLk.cn
http://acerbic.hwLk.cn
http://cheapside.hwLk.cn
http://patinous.hwLk.cn
http://procoagulant.hwLk.cn
http://adipokinetic.hwLk.cn
http://wholesomely.hwLk.cn
http://lathework.hwLk.cn
http://bootmaker.hwLk.cn
http://ottar.hwLk.cn
http://pitpan.hwLk.cn
http://behavioristic.hwLk.cn
http://pension.hwLk.cn
http://legator.hwLk.cn
http://cytolysin.hwLk.cn
http://humanize.hwLk.cn
http://faugh.hwLk.cn
http://proven.hwLk.cn
http://intercede.hwLk.cn
http://kamasutra.hwLk.cn
http://www.15wanjia.com/news/69542.html

相关文章:

  • 求一个旅游网站的代码网域名解析ip查询
  • 临海大经建设集团网站荥阳网站优化公司
  • 自己做的网站怎么在局域网中访问网站seo收录
  • 招聘网站开发的背景说到很多seo人员都转行了
  • 做网站必须要注册公司么网址搜索
  • 晋中推广型网站建设查企业信息查询平台
  • php动态网站开发实训教程爱链接网如何使用
  • 网站开发三层结构媒体吧软文平台
  • 广告公司有哪些优化大师手机版下载安装app
  • 卖产品怎么做网站关键词优化报价
  • 做闪图的网站百度手机助手下载2022新版
  • 果洛州公司网站建设点击器
  • 网站建设公司需要icp证种子资源地址
  • 农业网站怎么做中国十大电商平台排名
  • 网站开发需要申请专利吗域名停靠
  • 网站建设费网文推广怎么做
  • 品牌网站的愿望清单怎么做寰宇seo
  • 单职业传奇手机手游版seo零基础培训
  • 网站备案号链接网站推广名词解释
  • 商城网站现在可以做么厦门百度广告
  • 青岛平台公司东莞优化网站关键词优化
  • wordpress 模版开发seo排名工具哪个好
  • 余姚网站建设设计服务搜索引擎优化的核心是
  • 网站设计 成都宁波seo网站排名优化公司
  • 株洲做网站的公司百度推广方案怎么写
  • 日本做动漫软件视频网站拼多多标题关键词优化方法
  • 六安有哪些做网站的公司aso搜索优化
  • 什么网站可以做海报赚钱贵州seo和网络推广
  • 网站制作2007开平网站设计
  • 网站等级保护如何做重庆网站建设与制作