android 开机启动应用程序
16lz
2021-01-24
http://blog.csdn.net/yangwen123/article/details/8020818
版权声明:本文为博主原创文章,未经博主允许不得转载。
在开发过程中,有些应用需要随着系统启动而启动,那么如何实现应用程序开机启动呢?在Android 开机完毕后,会发送开机完成广播,因此只要编写广播接收器接收该广播,并启动应用程序即可。这种方式下只能使用广播接收器静态注册方式,因为应用程序的启动是由广播接收器启动。
[java] view plain copy
-
"com.spreadtrum.BroadcastReceiver.BootReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED"> -
- "android.intent.action.BOOT_COMPLETED">
- public class BootReceiver extends BroadcastReceiver {
- private static final String TAG = "BootReceiver";
- @Override
- public void onReceive(Context context, Intent intent) {
- this.context = context;
- // TODO Auto-generated method stub
- if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())){
- //启动应用程序
- context.startActivity(new Intent(context, MainActivity.class));
- }
- }
- }
Android关机广播
[cpp] view plain copy-
".ShutdownReceiver"> -
- "android.intent.action.ACTION_SHUTDOWN"/>
- 顶
- 0
- 踩
更多相关文章
- Android(安卓)数字签名
- Android(安卓)ashmem的实现方式
- Android上传图片的方式
- Android(安卓)Codec 集成和 video Overlay
- android编译系统学习
- Android(安卓)Activity之间切换出现短暂黑屏的处理方法
- Andriod编程入门知识
- 【Android】错误:Installation error: INSTALL_FAILED_VERSION_DO
- Android应用程序结构--比较偏的考试题目