当前位置: 首页>>代码示例>>Java>>正文


Java JobRequest.Builder方法代码示例

本文整理汇总了Java中com.evernote.android.job.JobRequest.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java JobRequest.Builder方法的具体用法?Java JobRequest.Builder怎么用?Java JobRequest.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.evernote.android.job.JobRequest的用法示例。


在下文中一共展示了JobRequest.Builder方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPeriodic

import com.evernote.android.job.JobRequest; //导入方法依赖的package包/类
@Override
public void createPeriodic() {
    for (int i = 0; i < 10; i++) {
        JobRequest.Builder builder = new JobRequest.Builder("tag")
                .setPeriodic(TimeUnit.MINUTES.toMillis(1))
                .setRequiresCharging(random())
                .setRequiresDeviceIdle(random())
                .setRequiredNetworkType(random() ? JobRequest.NetworkType.ANY : JobRequest.NetworkType.CONNECTED)
                .setRequirementsEnforced(random());

        if (random()) {
            PersistableBundleCompat extras = new PersistableBundleCompat();
            extras.putString("key", "Hello world");
            builder.setExtras(extras);
        }

        builder.build().schedule();
    }
}
 
开发者ID:evernote,项目名称:android-job,代码行数:20,代码来源:UnitTestDatabaseCreator.java

示例2: scheduleJob

import com.evernote.android.job.JobRequest; //导入方法依赖的package包/类
public static void scheduleJob(Context context) {
    JobRequest.Builder builder = new JobRequest.Builder(UpdateJob.TAG)
            .setUpdateCurrent(true);


    if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("data_saver", false)) {
        builder.setPeriodic(TimeUnit.DAYS.toMillis(7));
        Timber.v("DataSaver enabled - Scheduling periodic at seven days.");
    } else {
        builder.setPeriodic(TimeUnit.DAYS.toMillis(3));
        Timber.v("DataSaver not enabled - Scheduling periodic at default every three day.");
    }

    if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("wifi_only", false)) {
        builder.setRequiredNetworkType(JobRequest.NetworkType.UNMETERED);
        Timber.v("WiFi Only enabled");
    } else {
        builder.setRequiredNetworkType(JobRequest.NetworkType.CONNECTED);
        Timber.v("WiFi Only not-enabled");
    }

    Timber.i("Scheduling JobRequests for %s", TAG);
    builder.build().schedule();
    JobUtils.logJobRequest();
}
 
开发者ID:ItsCalebJones,项目名称:SpaceLaunchNow-Android,代码行数:26,代码来源:UpdateJob.java

示例3: schedulePeriodicJob

import com.evernote.android.job.JobRequest; //导入方法依赖的package包/类
public static void schedulePeriodicJob(Context context) {
    if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("background_sync", true)) {
        Timber.i("Background sync enabled, configuring JobRequest.");

        JobRequest.Builder builder = new JobRequest.Builder(SyncJob.TAG)
                .setUpdateCurrent(true);

        if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("data_saver", false)) {
            Timber.v("DataSaver mode enabled...periodic set to once per week.");
            builder.setPeriodic(TimeUnit.DAYS.toMillis(7), 7200000);
        } else {
            Timber.v("DataSaver mode not enabled...every day.");
            builder.setPeriodic(TimeUnit.HOURS.toMillis(24), 7200000);
        }

        Timber.i("Scheduling JobRequests for %s", TAG);
        builder.build().schedule();
        JobUtils.logJobRequest();
    }
}
 
开发者ID:ItsCalebJones,项目名称:SpaceLaunchNow-Android,代码行数:21,代码来源:SyncJob.java

示例4: scheduleNextPeriodicJob

import com.evernote.android.job.JobRequest; //导入方法依赖的package包/类
void scheduleNextPeriodicJob() {
    DateTime nextAlarmSwissTime = calculateNextAlarmTime(Instant.now(), RandomUtils.nextInt(0, 180));

    DateTime nowDeviceTime = DateTime.now();
    Duration windowStart = new Duration(nowDeviceTime, nextAlarmSwissTime);
    Duration windowEnd;
    if (!DEBUG) {
        windowEnd = new Duration(nowDeviceTime, nextAlarmSwissTime.plusMinutes(15));
    } else {
        windowEnd = windowStart;
    }

    JobRequest.Builder builder = new JobRequest.Builder(AutomaticIssueDownloadJob.TAG_PERIODIC)
            .setPersisted(true)
            .setRequirementsEnforced(false)
            .setUpdateCurrent(false)
            .setExecutionWindow(windowStart.getMillis(), windowEnd.getMillis());

    if (settings.isWifiOnly()) {
        builder.setRequiredNetworkType(JobRequest.NetworkType.UNMETERED);
    } else {
        builder.setRequiredNetworkType(JobRequest.NetworkType.CONNECTED);
    }

    builder.build().schedule();
}
 
开发者ID:notizklotz,项目名称:derbund-downloader,代码行数:27,代码来源:AutomaticDownloadScheduler.java

示例5: createBuilder

import com.evernote.android.job.JobRequest; //导入方法依赖的package包/类
public static JobRequest.Builder createBuilder(Class<? extends Job> jobClass) {
    try {
        String tag = (String) jobClass.getDeclaredField("TAG").get(null);
        return new JobRequest.Builder(tag);
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:evernote,项目名称:android-job,代码行数:9,代码来源:DummyJobs.java

示例6: scheduleJob

import com.evernote.android.job.JobRequest; //导入方法依赖的package包/类
public static void scheduleJob() {
    Timber.v("Scheduling UpdateWearJob...");

    JobRequest.Builder builder = new JobRequest.Builder(LibraryDataJob.TAG)
            .setPeriodic(TimeUnit.DAYS.toMillis(30))
            .setUpdateCurrent(true);

    builder.build().schedule();
}
 
开发者ID:ItsCalebJones,项目名称:SpaceLaunchNow-Android,代码行数:10,代码来源:LibraryDataJob.java

示例7: scheduleJob

import com.evernote.android.job.JobRequest; //导入方法依赖的package包/类
public static void scheduleJob() {
    Timber.v("Scheduling UpdateWearJob...");

    JobRequest.Builder builder = new JobRequest.Builder(SyncWearJob.TAG)
            .setPeriodic(TimeUnit.HOURS.toMillis(1), TimeUnit.MINUTES.toMillis(30))
            .setUpdateCurrent(true);

    builder.build().schedule();
}
 
开发者ID:ItsCalebJones,项目名称:SpaceLaunchNow-Android,代码行数:10,代码来源:SyncWearJob.java

示例8: scheduleJobNow

import com.evernote.android.job.JobRequest; //导入方法依赖的package包/类
public static void scheduleJobNow() {
    Timber.v("Scheduling UpdateWearJob...");

    JobRequest.Builder builder = new JobRequest.Builder(UpdateWearJob.TAG)
            .startNow()
            .setUpdateCurrent(true);

    builder.build().schedule();
}
 
开发者ID:ItsCalebJones,项目名称:SpaceLaunchNow-Android,代码行数:10,代码来源:UpdateWearJob.java

示例9: scheduleFallbackJob

import com.evernote.android.job.JobRequest; //导入方法依赖的package包/类
void scheduleFallbackJob() {
    JobRequest.Builder builder = new JobRequest.Builder(AutomaticIssueDownloadJob.TAG_FALLBACK)
            .setPersisted(false)
            .setRequirementsEnforced(false)
            .setUpdateCurrent(true)
            .setExecutionWindow(TimeUnit.MINUTES.toMillis(5), TimeUnit.MINUTES.toMillis(15));

    if (settings.isWifiOnly()) {
        builder.setRequiredNetworkType(JobRequest.NetworkType.UNMETERED);
    } else {
        builder.setRequiredNetworkType(JobRequest.NetworkType.CONNECTED);
    }

    builder.build().schedule();
}
 
开发者ID:notizklotz,项目名称:derbund-downloader,代码行数:16,代码来源:AutomaticDownloadScheduler.java

示例10: _scheduleJob

import com.evernote.android.job.JobRequest; //导入方法依赖的package包/类
private static void _scheduleJob(final Context context, final boolean shortInterval, final boolean forScreenOn, final boolean afterEnableWifi) {
    JobManager jobManager = null;
    try {
        jobManager = JobManager.instance();
    } catch (Exception ignored) { }

    if (jobManager != null) {
        final JobRequest.Builder jobBuilder;
        if (!shortInterval) {
            jobManager.cancelAllForTag(JOB_TAG_SHORT);

            int interval = ApplicationPreferences.applicationEventWifiScanInterval(context);
            //boolean isPowerSaveMode = PPApplication.isPowerSaveMode;
            boolean isPowerSaveMode = DataWrapper.isPowerSaveMode(context);
            if (isPowerSaveMode && ApplicationPreferences.applicationEventWifiScanInPowerSaveMode(context).equals("1"))
                interval = 2 * interval;

            jobBuilder = new JobRequest.Builder(JOB_TAG);

            if (TimeUnit.MINUTES.toMillis(interval) < JobRequest.MIN_INTERVAL) {
                jobManager.cancelAllForTag(JOB_TAG);
                jobBuilder.setExact(TimeUnit.MINUTES.toMillis(interval));
            } else {
                int requestsForTagSize = jobManager.getAllJobRequestsForTag(JOB_TAG).size();
                PPApplication.logE("WifiScanJob.scheduleJob", "requestsForTagSize=" + requestsForTagSize);
                if (requestsForTagSize == 0) {
                    if (TimeUnit.MINUTES.toMillis(interval) < JobRequest.MIN_INTERVAL)
                        // must be set min interval because:
                        //   java.lang.IllegalArgumentException: intervalMs is out of range of [900000, 9223372036854775807] (too low)
                        jobBuilder.setPeriodic(JobRequest.MIN_INTERVAL);
                    else
                        jobBuilder.setPeriodic(TimeUnit.MINUTES.toMillis(interval));
                } else
                    return;
            }
        } else {
            _cancelJob(context);
            jobBuilder = new JobRequest.Builder(JOB_TAG_SHORT);
            if (afterEnableWifi)
                jobBuilder.setExact(TimeUnit.SECONDS.toMillis(2));
            else if (forScreenOn)
                jobBuilder.setExact(TimeUnit.SECONDS.toMillis(5));
            else
                jobBuilder.setExact(TimeUnit.SECONDS.toMillis(5));
        }

        PPApplication.logE("WifiScanJob.scheduleJob", "build and schedule");

        try {
            jobBuilder
                    .setUpdateCurrent(false) // don't update current, it would cancel this currently running job
                    .build()
                    .schedule();
        } catch (Exception e) {
            PPApplication.logE("WifiScanJob.scheduleJob",e.toString());
        }
    }
}
 
开发者ID:henrichg,项目名称:PhoneProfilesPlus,代码行数:59,代码来源:WifiScanJob.java


注:本文中的com.evernote.android.job.JobRequest.Builder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。