更多内容请访问:Harmonyos技术社区https://harmonyos.51cto.com–1.在不同Slices之间跳转,同时在一个Ability中,优点是方便效率高,缺点是业务逻辑的复杂度有限;button.setClickedListener(listener->present(newSecondAbilitySlice(),newIntent()));–2.借助ElementName使用Intent,最常用的页面跳转方式,方便传递参数,实现相对复杂的业务逻辑交互;ElementNameelementName=newElementName(...);intent.setElement(elementName);intent.setParam(...);startAbility(意图);–3。操作,可实现跨应用页面跳转;Intentintent=newIntent();Operationoperation=newIntent.OperationBuilder().withDeviceId("").withBundleName("com.demoapp").withAbilityName("com.demoapp.FooAbility").build();intent.setOperation(operation);startAbility(intent);–4.Rout路由(JS),调用router.push()接口将uri指定的页面添加到路由栈中,即跳转到uri页面指定的页面。在调用路由器方法之前,需要导入路由器模块。调用router.push()路由到详情页;调用router.back()返回首页;//index.jsimportrouterfrom'@system.router';exportdefault{launch(){router.push({uri:'pages/detail/detail',});},}//detail.jsimportrouterfrom'@system.router';exportdefault{launch(){router.back();},}–5。通过迁移实现分布式设备间的页面传递(有请求迁移和请求迁移两种操作)1)需要实现IAbilityContinuation接口2)需要权限ohos.permission.GET_DISTRIBUTED_DEVICE_INFO:用于允许设备列表和设备信息在要获取的分布式网络ohos.permission.DISTRIBUTED_DATASYNC:用于允许不同设备之间的数据交换ohos.permission.DISTRIBUTED_DEVICE_STATE_CHANGE:用于允许在分布式网络中监控设备状态变化ohos.permission.READ_USER_STORAGE:读取内存中的内容cardohos.permission.WRITE_USER_STORAGE:修改或删除存储卡内容ohos.permission.GET_BUNDLE_INFO:用于查询其他应用信息ohos.permission.servicebus.ACCESS_SERVICE:分布式数据传输权限com.huawei.hwddmp.servicebus.BIND_SERVICE:系统申请权限3)需要o获取分布式设备ID(NetworkID)核心服务类:IContinuationRegisterManager服务类常用API方法:getContinuationRegisterManager();获取服务类的对象register();注册服务showDeviceList();获取设备列表unregister();注销服务4)请求迁移关键步骤(假设设备A迁移到设备B)需要迁移的页面实现IAbilityContinuation接口并重写onStartContinuation()方法,做迁移前准备,覆盖onSaveData()方法,保存迁移数据,覆盖设备B的onRestoreData()方法,恢复迁移数据,覆盖设备A的onCompleteContinuation()方法,以及迁移后调用continueAbility()或continueAbilityReversibly()发起迁移5)请求迁移,需要在设备A上调用reverseContinueAbility()请求迁移。以下关键步骤类似4)更多内容请访问:与华为官方共建的鸿蒙技术社区https://harmonyos.51cto.com
