Android开发之设置开机自动启动的几种方法
作者:wangyang2698341 时间:2021-12-04 20:35:37
Android开发之设置开机自动启动的几种方法
方法一:
<!-- 开机启动 -->
<receiver android:name=".AutoStartReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>
android:name=".AutoStartReceiver"为处理开机启动后所做操作的AutoStartReceiver.java
方法二:
在4.X版本上测试必须加入该句,测试设备原道N90 8G
<!-- 开机启动 -->
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
方法三:
AutoStartReceiver.Java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* 实现开机启动
* @author Owner
*/
public class AutoStartReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
来源:http://blog.csdn.net/wangyang2698341/article/details/8238094
标签:Android,自动启动
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Java设计模式之命令模式(Command模式)介绍
2021-12-02 01:01:02
C# PropertyInfo类案例详解
2021-12-11 16:47:45
集合嵌套之ArrayList嵌套ArrayList实例
2021-06-23 07:32:25
Java反射机制详解
2023-05-20 11:09:47
详解JAVA 弱引用
2022-03-12 01:30:29
Flutter刷新组件RefreshIndicator自定义样式demo
2023-07-06 15:56:45
![](https://img.aspxhome.com/file/2023/2/58272_0s.webp)
flutter实现底部导航栏
2023-08-23 01:06:13
![](https://img.aspxhome.com/file/2023/0/109150_0s.jpg)
深入理解Java序列化与反序列化
2023-01-24 00:27:53
![](https://img.aspxhome.com/file/2023/2/79182_0s.png)
Mybatis一对多关联关系映射实现过程解析
2021-07-13 06:22:59
![](https://img.aspxhome.com/file/2023/1/66031_0s.png)
通过实例解析Spring argNames属性
2023-09-14 10:43:13
![](https://img.aspxhome.com/file/2023/0/58540_0s.jpg)
android实现横屏的代码及思路
2023-06-25 09:35:40
Java基于ShardingSphere实现分库分表的实例详解
2022-04-20 18:43:37
![](https://img.aspxhome.com/file/2023/0/76270_0s.jpg)
利用thrift实现js与C#通讯的实例代码
2022-09-07 15:49:13
Java几个实例带你进阶升华下篇
2021-06-11 01:19:46
详解SpringBoot注入数据的方式
2022-05-09 06:34:24
![](https://img.aspxhome.com/file/2023/9/61929_0s.jpg)
解析C#中的私有构造函数和静态构造函数
2021-11-27 07:13:15
SpringBoot项目集成Flyway进行数据库版本控制的详细教程
2023-11-24 05:20:33
![](https://img.aspxhome.com/file/2023/0/59390_0s.png)
MyBatis 中 SqlMapConfig 配置文件详解
2023-10-19 21:23:01
Android实现截图和分享功能的代码
2023-04-09 22:56:43
![](https://img.aspxhome.com/file/2023/8/106868_0s.png)
mybatis @Alias注解在类上的使用方式(推荐)
2023-11-20 00:30:03