Pilldroid/app/src/main/java/net/foucry/pilldroid/PillDroidJobService.java

43 lines
1.1 KiB
Java
Raw Normal View History

2016-10-18 16:29:07 +02:00
package net.foucry.pilldroid;
import android.app.job.JobParameters;
import android.app.job.JobService;
2020-09-11 16:59:41 +02:00
import android.os.Handler;
import android.os.Message;
2016-10-18 16:29:07 +02:00
import android.util.Log;
/**
* Created by jacques on 17/09/16.
*/
public class PillDroidJobService extends JobService {
2020-09-11 16:59:41 +02:00
private static final String TAG = "JobService";
2020-09-11 16:59:41 +02:00
private Handler mJobHandler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
// Toast.makeText( getApplicationContext(), "PillDroid - Calcul nouveau stocks", Toast.LENGTH_SHORT).show();
// MedicamentListActivity.newStockCalculation(getApplicationContext());
2020-09-11 16:59:41 +02:00
jobFinished( (JobParameters) msg.obj,false);
return true;
}
2020-09-11 16:59:41 +02:00
});
2020-09-11 16:59:41 +02:00
@Override
public boolean onStartJob (JobParameters params) {
Log.i(TAG, "on Start Job: " + params.getJobId());
mJobHandler.sendMessage(Message.obtain(mJobHandler, 1,params));
return false;
2016-10-18 16:29:07 +02:00
}
@Override
public boolean onStopJob(JobParameters params) {
2020-09-11 16:59:41 +02:00
mJobHandler.removeMessages(1);
return false;
2016-10-18 16:29:07 +02:00
}
2020-08-21 10:34:12 +02:00
2020-09-11 16:59:41 +02:00
}
2020-08-21 10:34:12 +02:00