Methods Summary |
---|
public boolean | callJobFinished()
if (jobParamsMap.size() == 0) {
return false;
}
JobParameters params = jobParamsMap.valueAt(0);
if (params == null) {
return false;
} else {
jobFinished(params, false);
jobParamsMap.removeAt(0);
return true;
}
|
public void | onCreate()
super.onCreate();
Log.i(TAG, "Service created");
|
public void | onDestroy()
super.onDestroy();
Log.i(TAG, "Service destroyed");
|
public int | onStartCommand(android.content.Intent intent, int flags, int startId)
Messenger callback = intent.getParcelableExtra("messenger");
Message m = Message.obtain();
m.what = MainActivity.MSG_SERVICE_OBJ;
m.obj = this;
try {
callback.send(m);
} catch (RemoteException e) {
Log.e(TAG, "Error passing service object back to activity.");
}
return START_NOT_STICKY;
|
public boolean | onStartJob(android.app.job.JobParameters params)
Log.i(TAG, "on start job: " + params.getJobId());
currentId++;
jobParamsMap.put(currentId, params);
final int currId = this.currentId;
if (mActivity != null) {
mActivity.onReceivedStartJob(params);
}
Toast.makeText(
this, "On start job: '" + params.getJobId() + "' deadline exceeded: " +
params.isOverrideDeadlineExpired(),
Toast.LENGTH_LONG).show();
return true;
|
public boolean | onStopJob(android.app.job.JobParameters params)
Log.i(TAG, "on stop job: " + params.getJobId());
int ind = jobParamsMap.indexOfValue(params);
jobParamsMap.remove(ind);
mActivity.onReceivedStopJob();
return false; // no reschedule
|
public void | scheduleJob(android.app.job.JobInfo job)Send job to the JobScheduler.
Log.d(TAG, "Scheduling job " + job);
JobScheduler tm =
(JobScheduler) getSystemService(Context.JOB_SCHEDULER_SERVICE);
tm.schedule(job);
|
public void | setUiCallback(com.android.demo.jobSchedulerApp.MainActivity activity)
mActivity = activity;
|