android开机自启动app示例分享

来源:互联网 发布:备用域名 编辑:程序博客网 时间:2024/04/29 07:04
/*开机自动启动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");
    }
}
}
0 0
原创粉丝点击