http://blog.csdn.net/yangwen123/article/details/8020818


在开发过程中,有些应用需要随着系统启动而启动,那么如何实现应用程序开机启动呢?在Android 开机完毕后,会发送开机完成广播,因此只要编写广播接收器接收该广播,并启动应用程序即可。这种方式下只能使用广播接收器静态注册方式,因为应用程序的启动是由广播接收器启动。

[java]  view plain  copy
  1.   
  2. "com.spreadtrum.BroadcastReceiver.BootReceiver" android:permission="android.permission.RECEIVE_BOOT_COMPLETED">    
  3.       
  4.         "android.intent.action.BOOT_COMPLETED">  
  5.       
  6.   
  7.   
  8. public class BootReceiver extends BroadcastReceiver {  
  9.   
  10.     private static final String TAG = "BootReceiver";  
  11.   
  12.     @Override  
  13.     public void onReceive(Context context, Intent intent) {  
  14.          this.context = context;  
  15.         // TODO Auto-generated method stub  
  16.          if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())){  
  17.             //启动应用程序  
  18.             context.startActivity(new Intent(context, MainActivity.class));  
  19.          }  
  20.     }  
  21. }  

Android关机广播

[cpp]  view plain  copy
  1. ".ShutdownReceiver">    
  2.         
  3.         "android.intent.action.ACTION_SHUTDOWN"/>    
  4.         
  5.    

0

更多相关文章

  1. Android(安卓)数字签名
  2. Android(安卓)ashmem的实现方式
  3. Android上传图片的方式
  4. Android(安卓)Codec 集成和 video Overlay
  5. android编译系统学习
  6. Android(安卓)Activity之间切换出现短暂黑屏的处理方法
  7. Andriod编程入门知识
  8. 【Android】错误:Installation error: INSTALL_FAILED_VERSION_DO
  9. Android应用程序结构--比较偏的考试题目

随机推荐

  1. Attribute is missing the Android(安卓)
  2. Android中使EditText失去焦点,edittext禁
  3. CardView 设置水波纹效果
  4. Android(安卓)常用控件(三)学习笔记
  5. Android(安卓)Q : 安卓源码、水滴屏适配
  6. Android(安卓)Unable to resolve target
  7. android layout属性 .
  8. Cordova 3.x 基础(13) -- 为Android(安卓)A
  9. Android画图学习笔记一 类的简介
  10. Android(安卓)教你如何通过 LocationMana