Update BootCompletedReceiver.java
parent
308ceedbe5
commit
2314852b1c
|
|
@ -7,10 +7,17 @@ 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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue