1234567891011121314151617181920212223242526272829303132333435 |
- package com.bgy.autosale;
- import android.content.BroadcastReceiver;
- import android.content.Context;
- import android.content.Intent;
- import android.os.Build;
- import android.util.Log;
- import com.hboxs.base_library.util.LogUtil;
- import com.hboxs.base_library.util.LogUtils;
- /**
- * create by cjx on 2023/11/19
- */
- public class BootReceiver extends BroadcastReceiver {
- @Override
- public void onReceive(Context context, Intent intent) {
- Log.d("BootReceiver", "收到:" + intent.getAction());
- LogUtils.logWrite("安卓屏上电");
- if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {//开机启动广播
- Intent start = new Intent();
- start.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- start.setAction("com.bgy.action.main");
- start.setPackage(context.getPackageName());
- context.startActivity(start);
- Intent severIntent = new Intent(App.app, RemoteSupportService.class);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- context.startForegroundService(severIntent);
- } else {
- context.startService(severIntent);
- }
- }
- }
- }
|