本文整理汇总了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();
}
}
示例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();
}
示例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();
}
}
示例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();
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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());
}
}
}