本文整理了Java中com.evernote.android.job.JobRequest.getTransientExtras()方法的一些代码示例,展示了
本文整理了Java中com.evernote.android.job.JobRequest.getTransientExtras()
方法的一些代码示例,展示了JobRequest.getTransientExtras()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JobRequest.getTransientExtras()
方法的具体详情如下:
包路径:com.evernote.android.job.JobRequest
类名称:JobRequest
方法名:getTransientExtras
[英]Returns the transient extras you passed in when constructing this job with Builder#setTransientExtras(Bundle). WARNING: It's not guaranteed that a transient job will run at all, e.g. rebooting the device or force closing the app will cancel the job.
This will never be null. If you did not set any extras this will be an empty bundle. The returned bundle will also be empty, if the request isn't cached anymore.
[中]返回使用Builder#setTransientExtras(Bundle)构建此作业时传入的临时附加值。警告:不保证临时作业会运行,例如重新启动设备或强制关闭应用程序将取消作业。
这永远不会是空的。如果您没有设置任何附加项,这将是一个空包。如果请求不再缓存,则返回的捆绑包也将为空。
代码示例
代码示例来源:origin: evernote/android-job
@Override
protected JobInfo.Builder setTransientBundle(JobRequest request, JobInfo.Builder builder) {
return builder.setTransientExtras(request.getTransientExtras());
}
代码示例来源:origin: evernote/android-job
public static void persistBundle(@NonNull Context context, @NonNull JobRequest request) {
Intent intent = PlatformAlarmServiceExact.createIntent(context, request.getJobId(), request.getTransientExtras());
PendingIntent pendingIntent = PendingIntent.getService(context, request.getJobId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
long when = System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1000);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.setExact(AlarmManager.RTC, when, pendingIntent);
}
代码示例来源:origin: evernote/android-job
protected PendingIntent getPendingIntent(JobRequest request, int flags) {
return getPendingIntent(request.getJobId(), request.isExact(), request.getTransientExtras(), flags);
}
代码示例来源:origin: evernote/android-job
protected T prepareBuilder(T builder, JobRequest request) {
builder.setTag(createTag(request))
.setService(PlatformGcmService.class)
.setUpdateCurrent(true)
.setRequiredNetwork(convertNetworkType(request.requiredNetworkType()))
.setPersisted(JobUtil.hasBootPermission(mContext))
.setRequiresCharging(request.requiresCharging())
.setExtras(request.getTransientExtras());
return builder;
}
代码示例来源:origin: evernote/android-job
@Override
public void plantOneOff(JobRequest request) {
PendingIntent pendingIntent = getPendingIntent(request, false);
AlarmManager alarmManager = getAlarmManager();
if (alarmManager == null) {
return;
}
try {
if (request.isExact()) {
if (request.getStartMs() == 1 && request.getFailureCount() <= 0) {
// this job should start immediately
PlatformAlarmService.start(mContext, request.getJobId(), request.getTransientExtras());
} else {
plantOneOffExact(request, alarmManager, pendingIntent);
}
} else {
plantOneOffInexact(request, alarmManager, pendingIntent);
}
} catch (Exception e) {
// https://gist.github.com/vRallev/621b0b76a14ddde8691c
mCat.e(e);
}
}
代码示例来源:origin: evernote/android-job
@Override
public void plantOneOff(JobRequest request) {
if (request.isTransient()) {
TransientBundleHolder.putBundle(request.getJobId(), request.getTransientExtras());
}
OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(PlatformWorker.class)
.setInitialDelay(request.getStartMs(), TimeUnit.MILLISECONDS) // don't use the average here, WorkManager will do the right thing
.setConstraints(buildConstraints(request))
.addTag(createTag(request.getJobId()))
.build();
// don't set the back-off criteria, android-job is handling this
WorkManager workManager = getWorkManager();
if (workManager == null) {
throw new JobProxyIllegalStateException("WorkManager is null");
}
workManager.enqueue(workRequest);
}
代码示例来源:origin: henrichg/PhoneProfilesPlus
@Override
protected JobInfo.Builder setTransientBundle(JobRequest request, JobInfo.Builder builder) {
return builder.setTransientExtras(request.getTransientExtras());
}
代码示例来源:origin: henrichg/PhoneProfilesPlus
public static void persistBundle(@NonNull Context context, @NonNull JobRequest request) {
Intent intent = PlatformAlarmServiceExact.createIntent(context, request.getJobId(), request.getTransientExtras());
PendingIntent pendingIntent = PendingIntent.getService(context, request.getJobId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
long when = System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1000);
AlarmManager alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
alarmManager.setExact(AlarmManager.RTC, when, pendingIntent);
}
代码示例来源:origin: henrichg/PhoneProfilesPlus
protected PendingIntent getPendingIntent(JobRequest request, int flags) {
return getPendingIntent(request.getJobId(), request.isExact(), request.getTransientExtras(), flags);
}
代码示例来源:origin: henrichg/PhoneProfilesPlus
protected T prepareBuilder(T builder, JobRequest request) {
builder.setTag(createTag(request))
.setService(PlatformGcmService.class)
.setUpdateCurrent(true)
.setRequiredNetwork(convertNetworkType(request.requiredNetworkType()))
.setPersisted(JobUtil.hasBootPermission(mContext))
.setRequiresCharging(request.requiresCharging())
.setExtras(request.getTransientExtras());
return builder;
}
代码示例来源:origin: henrichg/PhoneProfilesPlus
@Override
public void plantOneOff(JobRequest request) {
PendingIntent pendingIntent = getPendingIntent(request, false);
AlarmManager alarmManager = getAlarmManager();
if (alarmManager == null) {
return;
}
try {
if (request.isExact()) {
if (request.getStartMs() == 1 && request.getFailureCount() <= 0) {
// this job should start immediately
PlatformAlarmService.start(mContext, request.getJobId(), request.getTransientExtras());
} else {
plantOneOffExact(request, alarmManager, pendingIntent);
}
} else {
plantOneOffInexact(request, alarmManager, pendingIntent);
}
} catch (Exception e) {
// https://gist.github.com/vRallev/621b0b76a14ddde8691c
mCat.e(e);
}
}