Service App-won';我不能在后台安卓工作室工作

Service App-won';我不能在后台安卓工作室工作,service,Service,我的应用程序不会在后台使用alarm manager、job scheduler甚至work manager运行。 我正在尝试每15分钟将设备位置发送到服务器。 我尝试了以上所有方法,但我的应用程序仍然无法运行。 我获得了所有需要的权限,甚至在后台运行该应用程序时,我使用power manager进行了操作、请求、忽略、电池等优化。 我实现了所有明显的需求。 我不会使用前台服务 现在我正在广播接收器中使用带有此代码的报警管理器 这是我的密码 主要活动 protected void onCreat

我的应用程序不会在后台使用alarm manager、job scheduler甚至work manager运行。 我正在尝试每15分钟将设备位置发送到服务器。 我尝试了以上所有方法,但我的应用程序仍然无法运行。 我获得了所有需要的权限,甚至在后台运行该应用程序时,我使用power manager进行了操作、请求、忽略、电池等优化。 我实现了所有明显的需求。 我不会使用前台服务

现在我正在广播接收器中使用带有此代码的报警管理器

这是我的密码

主要活动

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    startBroadcastLocation()
}

private void startBroadcastLocation() {
    Intent intent = new Intent(context, GetLocationServices.class);
    sendBroadcast(intent);
}
在我的广播里

public class GetLocationServices extends BroadcastReceiver {

private Context context;
private static final String SEND_DATA = "SEND_MY_LOCATION";
private static final String TAG = "TAG";
private boolean gps_enabled;
private String timeString, dateString;
private Intent intent;
private GoogleApiClient mGoogleApiClientLocation;
private LocationRequest mLocationRequest;
private Location mLocation;
private SQLiteDatabase sqLiteDatabase;
private ApiInterface apiInterface;
private LocationManager lm;
private Timer gpsTimer;
private SendApi sendApi;

@SuppressLint("UnsafeProtectedBroadcastReceiver")
@Override
public void onReceive(Context context, Intent intent) {

    this.context = context;

    sendApi = new SendApi(context);

    Intent intent2 = new Intent(context, GetLocationServices.class);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, 
    intent2, 0);

    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    calendar.set(Calendar.SECOND, 0);

    AlarmManager alarmManager = (AlarmManager) 
    context.getSystemService(ALARM_SERVICE);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, 
        calendar.getTimeInMillis() + 1000 * 60 * 1, pendingIntent);
    }


    apiInterface = API.getAPI().create(ApiInterface.class);

    getCurrentLocation();
}

private void getCurrentLocation() {
    MyLocation.LocationResult locationResult = new 
    MyLocation.LocationResult() {
        @Override
        public void gotLocation(Location location) {
            dateString = new CurrentDateAndTime().computeDate();
            timeString = new CurrentDateAndTime().computeTime();
           
            sendApi.sendLocation(location.getLongitude() + "", 
            location.getLatitude() + "", dateString, timeString);
        }
    };

        MyLocation myLocation = new MyLocation();
        myLocation.getLocation(context, locationResult);
    }
}
请帮帮我