当前位置:主页 > 移动开发 > Android代码 >

android开机自启动app示例分享

时间:2021-10-20 08:14:07 | 栏目:Android代码 | 点击:

复制代码 代码如下:

/*开机自动启动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");
    }
}
}

您可能感兴趣的文章:

相关文章