我试着用班级取消 JobService。我曾尝试使用 stopSelf(); 什么时候没有工作,我缺少什么才能让这个工作。
public class example extends JobService {
private boolean Working = false;
public boolean jobCancel = false;
private boolean example = false;
@Override
public boolean onStartJob(final JobParameters parameters){
Working = true;
runOnThread(parameters);
jobFinished(parameters, false);
return Working;
}
public void runOnThread(final JobParameters parameters){
new Thread(new Runnable() {
@Override
public void run() {
android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
if(example == true){
stopSelf();
}
}
}).start();
}
}