android监听开机 android.intent.action.BOOT_COMPLETED

来源:互联网 发布:自学编程 编辑:程序博客网 时间:2024/06/10 05:05

在Androidmainfest.xml文件中注册,action 为 android.intent.action.BOOT_COMPLETED

        <receiver android:name="com.noahedu.teachingvideo.msgpropell.BootcompleteReceiver" >                          <intent-filter>                                  <action android:name="android.intent.action.BOOT_COMPLETED" />                          </intent-filter>        </receiver>

然后在java文件中 监听 

package com.noahedu.teachingvideo.msgpropell;import android.content.BroadcastReceiver;import android.content.Context;import android.content.Intent;import android.util.Log;public class BootcompleteReceiver extends BroadcastReceiver{@Overridepublic void onReceive(Context context,Intent intent){if(Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {Log.v(PropellingService.TAG, "BootcompleteReceiver start!!!!!!!!!!!!!");PropellingUtils.startPropellingService(context,PropellingService.ACTION_SCHEDULE_COURSE); //启动提醒服务}}}



阅读全文
0 0
原创粉丝点击