当前位置:网站首页>监听开机广播
监听开机广播
2022-07-30 18:58:00 【菜鸟xiaowang】
1.manifest里注册
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<receiver
android:name=".BootCompleteReceiver"
android:exported="true">
<intent-filter android:priority="30000">
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>2.监听
public class BootCompleteReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { //开机启动完成后,要做的事情
Log.e(getClass().getName(), "BootBroadcastReceiver onReceive(), Do thing!");
context.startForegroundService(new Intent(context,MyService.class));
}
}
}边栏推荐
猜你喜欢

荐号 | 对你有恩的人,不要请吃饭来报答

Meta元宇宙部门第二季度亏损28亿!仍要继续押注?元宇宙发展尚未看到出路!

LeetCode 练习——关于查找数组元素之和的两道题

Does the satellite phone communicate directly with the satellite or through a ground station?

【总结】1396- 60+个 VSCode 插件,打造好用的编辑器

自然语言处理nltk

【Pointing to Offer】Pointing to Offer 18. Delete the node of the linked list

Fixed asset visualization intelligent management system

使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported

Node encapsulates a console progress bar plugin
随机推荐
【每日一道LeetCode】——191. 位1的个数
OSPF详解(4)
使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported
几个GTest、GMock的例子
《痞子衡嵌入式半月刊》 第 59 期
CCNA-网络汇总 超网(CIDR) 路由最长掩码匹配
Pytorch基础--tensorboard使用(一)
高精度加法
智慧中控屏
[Summary] 1396- 60+ VSCode plugins to create a useful editor
开心的聚餐
【Pointing to Offer】Pointing to Offer 22. The kth node from the bottom in the linked list
AI基础:图解Transformer
AWS console
Common linked list problems and their Go implementation
Multiple instances of mysql
SwiftUI iOS Boutique Open Source Project Complete Baked Food Recipe App based on SQLite (tutorial including source code)
requet.getHeader("token") is null
VBA批量将Excel数据导入Access数据库
Basic use of scrapy