服务模块启动参数BugFix.

This commit is contained in:
ZhanGSKen
2025-10-28 14:12:32 +08:00
parent 377ec4de09
commit 298b337392

View File

@@ -630,9 +630,12 @@ public class MainService extends Service {
*/ */
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
boolean isSettingToEnable = intent.getBooleanExtra(EXTRA_IS_SETTING_TO_ENABLE, false); boolean isSettingToEnable = false;
if (isSettingToEnable) { if (intent != null) {
run(); // 重启服务核心逻辑(保证服务启动后进入运行状态) isSettingToEnable = intent.getBooleanExtra(EXTRA_IS_SETTING_TO_ENABLE, false);
if (isSettingToEnable) {
run(); // 重启服务核心逻辑(保证服务启动后进入运行状态)
}
} }
// 如果被设置为自启动就返回START_STICKY服务被异常杀死后系统会尝试重启原逻辑保留 // 如果被设置为自启动就返回START_STICKY服务被异常杀死后系统会尝试重启原逻辑保留
@@ -904,7 +907,7 @@ public class MainService extends Service {
} }
LogUtils.i(TAG, "任务触发通知:" + triggerContent); LogUtils.i(TAG, "任务触发通知:" + triggerContent);
} }
/** /**
* 更新前台通知的GPS状态Java 7 主线程切换匿名Runnable实现 * 更新前台通知的GPS状态Java 7 主线程切换匿名Runnable实现