码迷,mamicode.com
首页 > 移动开发 > 详细

android开机自启动广播

时间:2015-04-26 01:18:43      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:

权限<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

 

    <span style="color: #ff00ff;"><receiver android:name=".BootBroadcastReceiver">
        <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <category android:name="android.intent.category.HOME" />
        </intent-filter>
    </receiver>
 
 
public class BootBroadcastReceiver extends BroadcastReceiver {
    static final String action_boot="android.intent.action.BOOT_COMPLETED";
 
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent.getAction().equals(action_boot)){
            Intent ootStartIntent=new Intent(context,BootStartDemo.class);
            ootStartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(ootStartIntent);
        }
 
    }
 
}

android开机自启动广播

标签:

原文地址:http://www.cnblogs.com/lzh-Linux/p/4457151.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!