26 lines
912 B
Java
26 lines
912 B
Java
package com.nbee.echolink.broadcast;
|
|
|
|
import android.content.BroadcastReceiver;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
|
|
import com.nbee.echolink.service.MonitorService;
|
|
|
|
public class BootCompletedReceiver extends BroadcastReceiver {
|
|
/**
|
|
* 当接收到开机启动完成的广播时启动监控服务。
|
|
*
|
|
* @param context 上下文对象,提供了调用环境的信息。
|
|
* @param intent 携带了广播的内容。
|
|
*/
|
|
@Override
|
|
public void onReceive(Context context, Intent intent) {
|
|
// 检查接收到的广播是否为系统启动完成的广播
|
|
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
|
|
// 如果是系统启动完成的广播,则启动监控服务
|
|
Intent serviceIntent = new Intent(context, MonitorService.class);
|
|
context.startService(serviceIntent);
|
|
}
|
|
}
|
|
}
|