软件编程
位置:首页>> 软件编程>> Android编程>> android开机自启动app示例分享

android开机自启动app示例分享

  发布时间:2023-02-20 18:04:29 

标签:开机自启动,启动app


/*开机自动启动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
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com