脚本必备
想必不少人都在为脚本被后台误杀导致脚本停止运行以至于让脚本压根运行不了多久的烦恼
那么这里给大家免费提供一个免费的前台保活源码
步骤如下:
①授权软件—通知使用权限(测试则授予autojs—通知使用权).
②脚本运行前运行代码:
//定义
/** 前台服务保活 */
let KeepAliveService = {
/** 开启 */
start: function (idStr, nameStr) {
try {
idStr = idStr || "";
let channel_id = idStr + ".foreground";
let channel_name = nameStr + " 前台服务通知";
let content_title = nameStr + " 正在运行中";
let content_text = "此为前台保活,请勿手动移除该通知";
let ticker = nameStr + "已启动";
let manager = context.getSystemService(android.app.Service.NOTIFICATION_SERVICE);
let notification;
let icon = context.getResources().getIdentifier("ic_3d_rotation_black_48dp", "drawable", context.ge