android开机自启动广播

权限<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);
        }
 
    }
 
}
posted @ 2015-04-26 00:02  Android开发8585  阅读(472)  评论(0编辑  收藏  举报