当前位置:网站首页>监听开机广播
监听开机广播
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));
}
}
}
边栏推荐
- Basic use of scrapy
- Meta元宇宙部门第二季度亏损28亿!仍要继续押注?元宇宙发展尚未看到出路!
- 防抖和节流有什么区别,分别用于什么场景?
- ESP8266-Arduino programming example-HC-SR04 ultrasonic sensor driver
- 自然语言处理nltk
- Fixed asset visualization intelligent management system
- The Meta metaverse division lost 2.8 billion in the second quarter!Still want to keep betting?Metaverse development has yet to see a way out!
- - daily a LeetCode 】 【 191. A number of 1
- 【Pointing to Offer】Pointing to Offer 22. The kth node from the bottom in the linked list
- ROS 节点初始化步骤、topic/service创建及使用
猜你喜欢
Swiper轮播图片并播放背景音乐
使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported
OSPF详解(4)
A senior with 13 years of experience in software testing, summed up 5 test employment suggestions....
Scrapy framework is introduced
Mysql execution principle analysis
The use of @ symbol in MySql
OneFlow source code analysis: Op, Kernel and interpreter
NC | Tao Liang Group of West Lake University - TMPRSS2 "assists" virus infection and mediates the host invasion of Clostridium sothrix hemorrhagic toxin...
【网站放大镜效果】两种方式实现
随机推荐
The large-scale application of artificial intelligence AI products in industrial-grade mature shipping ports of CIMC World Lianda will create a new generation of high-efficiency smart ports and innova
The use of @ symbol in MySql
实体中增加操作方法
智慧中控屏
荐号 | 对你有恩的人,不要请吃饭来报答
解决终极bug,项目最终能顺利部署上线。
432.4 FPS 快STDC 2.84倍 | LPS-Net 结合内存、FLOPs、CUDA实现超快语义分割模型
Scrapy framework is introduced
Recommended Books | Recommend 3 database books with rave reviews
第14章 类型信息
Delay queue optimization (2)
7.30模拟赛总结
VBA 运行时错误‘-2147217900(80040e14):自动化(Automation)错误
【Pointing to Offer】Pointing to Offer 22. The kth node from the bottom in the linked list
The use of terminal split screen tool Terminalx
【Prometheus】Prometheus联邦的一次优化记录[续]
电脑死机的时候,发生了什么?
kotlin by lazy
使用postman调接口报Content type ‘text/plain;charset=UTF-8‘ not supported
CCNA-网络汇总 超网(CIDR) 路由最长掩码匹配