当前位置:网站首页>监听开机广播
监听开机广播
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));
}
}
}边栏推荐
- Common linked list problems and their Go implementation
- 【剑指 Offe】剑指 Offer 18. 删除链表的节点
- ROS 环境使用第三方动态链接库(.so)文件
- Chapter 14 Type Information
- Spark学习:编译Spark项目时遇到的报错
- Critical Reviews | 南农邹建文组综述全球农田土壤抗生素与耐药基因分布
- 使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported
- What kind of framework is friendly to developers?
- CMake库搜索函数居然不搜索LD_LIBRARY_PATH
- DM8:单库单实例搭建本地数据守护服务
猜你喜欢

开心的聚餐

6块钱1斤,日本公司为何来中国收烟头?

OneFlow源码解析:Op、Kernel与解释器

nlohmann json 使用指南【visual studio 2022】

Pytorch foundation -- tensorboard use (1)

中集世联达飞瞳全球工业人工智能AI领军者,全球顶尖AI核心技术高泛化性高鲁棒性稀疏样本持续学习,工业级高性能成熟AI产品规模应用

The sixteenth issue of eight-part article Balabala said (MQ)

OSPF详解(3)
![[Prometheus] An optimization record of the Prometheus federation [continued]](/img/5d/56e171b7a02584337a0cfe5c731fb2.png)
[Prometheus] An optimization record of the Prometheus federation [continued]

ESP8266-Arduino programming example-HC-SR04 ultrasonic sensor driver
随机推荐
Scala学习:类和对象
线性筛求积性函数
沉浸式体验科大讯飞2022消博会“官方指定产品”
2种手绘风格效果比较,你更喜欢哪一种呢?
After 23 years of operation, the former "China's largest e-commerce website" has turned yellow...
Two-point answer naked question (plus a little pigeonhole principle)
使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported
OneFlow source code analysis: Op, Kernel and interpreter
432.4 FPS 快STDC 2.84倍 | LPS-Net 结合内存、FLOPs、CUDA实现超快语义分割模型
Node encapsulates a console progress bar plugin
高并发秒杀项目总结
LeetCode Exercise - Two Questions About Finding Sum of Array Elements
Vulkan开启特征(feature)的正确姿势
CCNA-网络汇总 超网(CIDR) 路由最长掩码匹配
LocalDate时间生成
第4章 控制执行流程
【刷题篇】计算质数
Codeblocks + Widgets create window code analysis
中集世联达工业级成熟航运港口人工智能AI产品规模化应用,打造新一代高效能智慧港口和创新数字港口,全球港航人工智能能领军者中集飞瞳
6块钱1斤,日本公司为何来中国收烟头?