public void onTaskRemoved(Intent rootIntent) {
startMainService();
}
public void startMainService(){
startService(MainService.getIntentAlarm(this));
}
}
注册JobSchedulerService
<service
android:name=“com.aoaoyi.service.JobSchedulerService”
android:permission=“android.permission.BIND_JOB_SERVICE”
android:enabled=“true”
android:exported=“true”
android:process=":push"/>
权限
MainService
package com.aoaoyi.service;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.Service;
import android.app.job.JobInfo;
import android.app.job.JobScheduler;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
pub