分布式流转开发常见报错FAQ
鸿蒙入门指南,小白速来!0基础学习路线分享,高效学习方法,重点答疑解惑--->【课程入口】
HarmonyOS开发中分布式协同是非常重要的一个功能,大家在刚接触的时候可能会出现各种各样的错误。我在此总结下在进行分布式流转开发过程中常见的一些坑和解决办法,希望可以帮助到各位。
1、查找不到设备列表的报错,如下图

解决措施如下:
(1)检查wifi是否在同一网络
(2)华为账号是否登录,设备是否都是登录的相同的华为账号
(3)手机设置中“分布式协同”是否开启。
2、This ability do not support continuation.
该错误的原因是因为只在Slice中实现了IAbilityContinuation接口,而没有在Slice对应的ability中也实现该接口,解决方案就是在ability中实现IAbilityContinuation接口
package com.xdw.demo;
import com.xdw.demo.slice.MigrationAbilitySlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.ability.IAbilityContinuation;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.IntentParams;
public class MigrationAbility extends Ability implements IAbilityContinuation {
@Override
public void onStart(Intent intent) {
super.onStart(intent);
super.setMainRoute(MigrationAbilitySlice.class.getName());
}
@Override
public boolean onStartContinuation() {
return true;
}
@Override
public boolean onSaveData(IntentParams intentParams) {
return true;
}
@Override
public boolean onRestoreData(IntentParams intentParams) {
return true;
}
@Override
public void onCompleteContinuation(int i) {
}
@Override
public void onRemoteTerminated() {
}
}
3、handleStartContinuation: Ability rejected. 流转被拒绝
产生该错误的线上是不会产生crash,也不会生成error日志,而是打印的info日志。表现就是并没有进行流转。
产生的原因是实现IAbilityContinuation接口中的onStartContinuation方法返回的是false,修改办法就是将返回值修改为true。

4、handleStartContinuation: ScheduleSaveData failed
产生该错误的线上是不会产生crash,也不会生成error日志,而是打印的warn日志。表现也是并没有进行流转。
产生的原因是实现IAbilityContinuation接口中的onSaveData方法返回的是false,修改办法就是将返回值修改为true。

5、能正常流转启动FA,但是没有传递过去数据
这里能正常流转,也不会有相关报错日志打印,只是业务逻辑错误。能正常流转,但是没有数据传递,产生的原因是实现IAbilityContinuation接口中的onRestoreData方法返回的是false,修改办法就是将返回值修改为true。
最后代码如下:
package com.xdw.demo;
import com.xdw.demo.slice.MigrationAbilitySlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.ability.IAbilityContinuation;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.IntentParams;
public class MigrationAbility extends Ability implements IAbilityContinuation {
@Override
public void onStart(Intent intent) {
super.onStart(intent);
super.setMainRoute(MigrationAbilitySlice.class.getName());
}
@Override
public boolean onStartContinuation() {
return true;
}
@Override
public boolean onSaveData(IntentParams intentParams) {
return true;
}
@Override
public boolean onRestoreData(IntentParams intentParams) {
return true;
}
@Override
public void onCompleteContinuation(int i) {
}
}
作者:软通夏德旺
想了解更多内容,请访问51CTO和华为合作共建的鸿蒙社区:https://harmonyos.51cto.com
分布式流转开发常见报错FAQ的更多相关文章
- React 开发常见报错解决方法
1. 使用 redux 的异步 action 时浏览器报错: Error: Actions must be plain objects. Use custom middleware for async ...
- C语言开发中常见报错的解决方案
C语言开发中常见报错的解决方案 整理来源于网络,侵权请通知删除.*禁止转载 ---- fatal error C1003: error count exceeds number; stopping c ...
- java常见报错及解决
Java常见报错信息: Java 常见异常种类 Java Exception: 1.Error 2.Runtime Exception 运行时异常 3.Exception 4.throw 用户自定 ...
- Git常用命令及常见报错:You have not concluded your merge (MERGE_HEAD exists)、清理无效的远程追踪分支
一.常用命令 切换到master分支:git checkout master 查看已有本地及远程分支:git branch -a(先git pull拉下全部数据) 查看远程分支:git branch ...
- web报表工具FineReport使用中遇到的常见报错及解决办法(二)
web报表工具FineReport使用中遇到的常见报错及解决办法(二) 这里写点抛砖引玉,希望大家能把自己整理的问题及解决方法晾出来,Mark一下,利人利己. 出现问题先搜一下文档上有没有,再看看度娘 ...
- HDFS集群常见报错汇总
HDFS集群常见报错汇总 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.DataXceiver error processing WRITE_BLOCK operation 报 ...
- 03:git常见报错解决方法
1.1 git常见报错解决方法 1.warning: LF will be replaced by CRLF in .idea/workspace.xml. 参考博客:https://www.cnbl ...
- JavaScript 调试常见报错以及原因
JavaScript 调试常见报错以及原因 测试环境 chrome 版本 66.0.3359.170(正式版本) (64 位) TypeError 类型错误 不是操作符所接受的数据类型. //---- ...
- Nginx 常见报错
Nginx 常见报错 启动报错:[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) 原因:这个是nginx重启时经常遇到 ...
随机推荐
- dedecms织梦后台栏目显示文档数不为0,但点进去之后什么都没有
曾经通过sql语句直接删除过dede_addonarticle或者dede_archives或者dede_arctiny中的记录,这三个表是有关联的,如果要通过sql语句删除内容,一定要同时将这三个表 ...
- js实现购物车左滑删除
使用 js 和jquery动画实现购物车左滑,请引入jquery库,不然会报错哦! 首页编写页面,注意布局,滑动分成两部分,商品图片和信息放在一个布局,删除和移入收藏放在一起. 其中js用到了 tou ...
- F - F(最小生成树)
题意:连通各点最短距离,最小生成树. You are assigned to design network connections between certain points in a wide a ...
- BZOJ2555 SubString【SAM + Link Cut Tree】
BZOJ2555. SubString 要求在线询问一个串在原串中出现的次数,并且可以在原串末尾添加字符串 如果没有修改的话,考虑建出\(parent\)树之后统计每个\(endpos\)节点的\(r ...
- zjnu1730 PIRAMIDA(字符串,模拟)
Description Sample Input 6 JANJETINA 5 1 J 1 A 6 N 6 I 5 E Sample Output 1 0 2 1 1 题意:给你一个长度小于等于10^6 ...
- zjnuSAVEZ (字符串hash)
Description There are eight planets and one planetoid in the Solar system. It is not a well known fa ...
- c语言实现--不带头结点的单链表操作
1,不带头结点的单链表操作中,除了InitList(),GetElem(),ListInsert(),ListDelete()操作与带头结点的单链表有差别外,其它的操作基本上一样. 2,不带头结点单链 ...
- 单源最短路问题 Dijkstra 算法(朴素+堆)
选择某一个点开始,每次去找这个点的最短边,然后再从这个开始不断迭代,更新距离. 代码: 朴素(vector存图) #include <iostream> #include <cstd ...
- .Net反编译实践记录
去壳 去壳可以使用 de4dot,源码在 这里.可用版本 下载地址. 使用方式为:.\de4dot.exe [path] 修改代码 反编译修改代码可以使用 dnSpy,源码在 这里.可用版本 下载地址 ...
- VMX - block by NMI和 NMI unblockinig due to IRET 之间的关系
相关SDM章节: 27.2.3- Information About NMI Unblocking Due to IRET 最近收到同事发来的一个问题,即: VMCS 中的 Guest Interru ...