package com.miraclegarden.smsmessage.service; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.os.Handler; import android.os.Looper; /** * 开机后重启监听服务。 */ public class BootReceiver extends BroadcastReceiver { private static final long BOOT_DELAY_MS = 5000; @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (Intent.ACTION_BOOT_COMPLETED.equals(action)) { new Handler(Looper.getMainLooper()).postDelayed(() -> { if (NotificationService.isMonitoringActive(context)) { NotificationService.requestStartMonitoring(context); } }, BOOT_DELAY_MS); } } }