欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

android开机自启动app示例分享

程序员文章站 2022-06-29 09:41:02
复制代码 代码如下:/*开机自动启动app*/public class bootreceiver extends broadcastreceiver { @overrid...

复制代码 代码如下:

/*开机自动启动app*/
public class bootreceiver extends broadcastreceiver {

@override
public void onreceive(context context, intent intent) {

log.d("xrgps", "bootreceiver.onreceive: " + intent.getaction());
if (action_boot_completed.equals(intent.getaction())) {
           intent mbootintent = new intent(context, mainactivity.class);
           mbootintent.setflags(intent.flag_activity_new_task);
           context.startactivity(mbootintent); 
    } else {
        log.w("xrgps", "bootreceiver: unsupported action");
    }
}
}