酷安APP 发现科技新生活

Jinamin

2023-04-23 红米Note 9

写情景模式最好不要使用“Thread.sleep()”,凡是使用过这个延迟命令的,时间不到不会终止,无法打断。
前些天下载了在线库中的“保持后台”,结果,放入列表的应用返回桌面被清理后马上再次打开,这个情景模式会在所有延迟结束后被清理后台的情景模式再次清理,造成闪退假象。除非等上十几秒等待所有延迟结束后才能正常操作。下面是我修改过的保后台情景和清理后台的情景。
[
{
"name": "保活APP",
"description": "APP被杀死时,重新启动,全局变量keepAlive",
"priority": 1,
"condition": "pkgKilled == true && globalVarOf$keepAlive.contains(pkgName)",
"actions": [
"activity.launchProcessForPackage(pkgName)",
"if(thanos.activityManager.hasRunningServiceForPackage(pkgName)){ui.showShortToast(\"👻\" + thanos.pkgManager.getAppInfo(pkgName).appLabel +\"启动成功\")}else{activity.launchProcessForPackage(pkgName)}"
]
}
]
[
{
"name": "返回桌面移除任务卡片",
"description": "返回桌面(变量HomeApp)移除全局变量Task列表中的应用任务卡片",
"priority": 1,
"condition": " frontPkgChanged == true && globalVarOf$HomeApp.contains(to) && globalVarOf$Task.contains(from) && task.hasTaskFromPackage(from)",
"actions": [
"task.removeTasksForPackage(from)",
"ui.showShortToast(\"🌪️移除\" + thanos.pkgManager.getAppInfo(from).appLabel +\"任务🌪️\")"
]
}
]

Thanox
30
18