ecovery捕获应用崩溃框架,并能恢复崩溃页面。
1.安装教程
在项目根目录下的build.gradle文件中添加。
allprojects {
repositories {
maven {
url'https://s01.oss.sonatype.org/content/repositories/releases/'
}
}}
在entry模块下的build.gradle文件中添加依赖。
dependencies { implementation('com.gitee.chinasoft_ohos:Recovery:1.0.1')}
在sdk6,DevEco Studio2.2 beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
使用说明
在entry下的MyApplication中调用
public class MyApplication extends AbilityPackage {
@Override
public void onInitialize() {
super.onInitialize();
Recovery.getInstance()
.debug(true)
.recoverInBackground(false)
.recoverStack(true)
.mainPage(MainAbility.class)
.recoverEnabled(true)
.callback(new MyCrashCallback())
.silent(false, Recovery.SilentMode.RECOVER_ACTIVITY_STACK)
.skip(TestAbility.class)
.init(this);
}
static final class MyCrashCallback implements RecoveryCallback {
@Override
public void stackTrace(String exceptionMessage) {
RecoveryLog.e("exceptionMessage:" + exceptionMessage);
}
@Override
public void cause(String cause) {
RecoveryLog.e("cause:" + cause);
}
@Override
public void exception(String exceptionType, String throwClassName, String throwMethodName, int throwLineNumber) {
RecoveryLog.e("exceptionType:" + exceptionType);
RecoveryLog.e("throwClassName:" + throwClassName);
RecoveryLog.e("throwMethodName:" + throwMethodName);
RecoveryLog.e("throwLineNumber:" + throwLineNumber);
}
@Override
public void throwable(Throwable throwable) {
}
}
}
2.重启功能需要在entry模块的config.json中 module 加入属性mainAbility
"module": { "mainAbility" : "启动页的路径", .....}
3.组件完整代码地址
https://gitee.com/jltfcloudcn/jump_to/tree/master/Recovery%E5%BA%94%E7%94%A8%E5%B4%A9%E6%BA%83%E6%A1%86%E6%9E%B6%E7%BB%84%E4%BB%B6%E4%BD%93%E9%AA%8C
全部0条评论
快来发表一下你的评论吧 !