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

xiaoxiao2021-02-27  223

在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 { @Override public 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); //启动提醒服务 } } }

转载请注明原文地址: https://www.6miu.com/read-9314.html

最新回复(0)