mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 04:29:22 +01:00
Ajout jobService
This commit is contained in:
parent
42efe6f9ad
commit
0e4e3ec9ff
1 changed files with 43 additions and 0 deletions
|
@ -0,0 +1,43 @@
|
|||
package net.foucry.pilldroid;
|
||||
|
||||
import android.app.job.JobParameters;
|
||||
import android.app.job.JobService;
|
||||
import android.os.Message;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
/**
|
||||
* Created by jacques on 17/09/16.
|
||||
*/
|
||||
public class PillDroidJobService extends JobService {
|
||||
private static final String TAG = "JobService";
|
||||
|
||||
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();
|
||||
|
||||
jobFinished( (JobParameters) msg.obj,false);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public boolean onStartJob (JobParameters params) {
|
||||
Log.i(TAG, "on Start Job: " + params.getJobId());
|
||||
mJobHandler.sendMessage(Message.obtain(mJobHandler, 1,params));
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStopJob(JobParameters params) {
|
||||
mJobHandler.removeMessages(1);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in a new issue