Search in sources :

Example 11 with JobManager

use of com.evernote.android.job.JobManager in project PhoneProfilesPlus by henrichg.

the class AboutApplicationJob method _scheduleJob.

private static void _scheduleJob() /*final Context context*/
{
    JobManager jobManager = null;
    try {
        jobManager = JobManager.instance();
    } catch (Exception ignored) {
    }
    if (jobManager != null) {
        final JobRequest.Builder jobBuilder;
        int requestsForTagSize = jobManager.getAllJobRequestsForTag(JOB_TAG).size();
        PPApplication.logE("AboutApplicationJob.scheduleJob", "requestsForTagSize=" + requestsForTagSize);
        if (requestsForTagSize == 0) {
            jobBuilder = new JobRequest.Builder(JOB_TAG);
            // each 24 hours
            jobBuilder.setPeriodic(TimeUnit.DAYS.toMillis(1));
        } else
            return;
        PPApplication.logE("AboutApplicationJob.scheduleJob", "build and schedule");
        try {
            jobBuilder.setUpdateCurrent(// don't update current, it would cancel this currently running job
            false).build().scheduleAsync();
        } catch (Exception ignored) {
        }
    }
}
Also used : JobRequest(com.evernote.android.job.JobRequest) JobManager(com.evernote.android.job.JobManager)

Example 12 with JobManager

use of com.evernote.android.job.JobManager in project PhoneProfiles by henrichg.

the class AboutApplicationJob method _scheduleJob.

private static void _scheduleJob() /*final Context context*/
{
    JobManager jobManager = null;
    try {
        jobManager = JobManager.instance();
    } catch (Exception ignored) {
    }
    if (jobManager != null) {
        final JobRequest.Builder jobBuilder;
        int requestsForTagSize = jobManager.getAllJobRequestsForTag(JOB_TAG).size();
        PPApplication.logE("AboutApplicationJob.scheduleJob", "requestsForTagSize=" + requestsForTagSize);
        if (requestsForTagSize == 0) {
            jobBuilder = new JobRequest.Builder(JOB_TAG);
            // each 24 hours
            jobBuilder.setPeriodic(TimeUnit.DAYS.toMillis(1));
        } else
            return;
        PPApplication.logE("AboutApplicationJob.scheduleJob", "build and schedule");
        try {
            jobBuilder.setUpdateCurrent(// don't update current, it would cancel this currently running job
            false).build().scheduleAsync();
        } catch (Exception ignored) {
        }
    }
}
Also used : JobRequest(com.evernote.android.job.JobRequest) JobManager(com.evernote.android.job.JobManager)

Aggregations

JobManager (com.evernote.android.job.JobManager)12 JobRequest (com.evernote.android.job.JobRequest)8 PersistableBundleCompat (com.evernote.android.job.util.support.PersistableBundleCompat)2 SuppressLint (android.annotation.SuppressLint)1