·您现在的位置: 云翼网络 >> 文章中心 >> 网站建设 >> app软件开发 >> Android开发 >> android开机自启动app示例分享

android开机自启动app示例分享

作者:佚名      Android开发编辑:admin      更新时间:2022-07-23

复制代码 代码如下:
/*开机自动启动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");
    }
}
}