use of com.firebase.jobdispatcher.Job in project Applozic-Android-SDK by AppLozic.
the class PushNotificationDispatcher method scheduleJob.
public static void scheduleJob(Context context, Message message) {
try {
Bundle bundle = new Bundle();
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
bundle.putString(MobiComKitConstants.AL_MESSAGE_KEY, message.getKeyString());
Class pushNotificationJobServiceClass = Class.forName("com.applozic.mobicomkit.uiwidgets.notification.PushNotificationJobService");
Job myJob = dispatcher.newJobBuilder().setService(// the JobService that will be called
pushNotificationJobServiceClass).setTag(// uniquely identifies the job
MobiComKitConstants.PUSH_NOTIFICATION_DISPATCHER).setRecurring(false).setTrigger(Trigger.executionWindow(0, 0)).setReplaceCurrent(true).setRetryStrategy(RetryStrategy.DEFAULT_LINEAR).setConstraints(Constraint.ON_ANY_NETWORK).setExtras(bundle).build();
dispatcher.mustSchedule(myJob);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.
the class BackupJobsTest method shouldScheduleContentUriTriggerForCallLogIfEnabled.
@Test
public void shouldScheduleContentUriTriggerForCallLogIfEnabled() throws Exception {
when(preferences.isCallLogBackupAfterCallEnabled()).thenReturn(true);
when(dataTypePreferences.isBackupEnabled(CALLLOG)).thenReturn(true);
Job job = subject.scheduleContentTriggerJob();
assertThat(job.getTrigger()).isInstanceOf(JobTrigger.ContentUriTrigger.class);
JobTrigger.ContentUriTrigger contentUriTrigger = (JobTrigger.ContentUriTrigger) job.getTrigger();
assertThat(contentUriTrigger.getUris()).containsExactly(new ObservedUri(SMS_PROVIDER, FLAG_NOTIFY_FOR_DESCENDANTS), new ObservedUri(CALLLOG_PROVIDER, FLAG_NOTIFY_FOR_DESCENDANTS));
}
use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.
the class BackupJobsTest method shouldCancelAllJobsAfterBootIfAutoBackupDisabled.
@Test
public void shouldCancelAllJobsAfterBootIfAutoBackupDisabled() throws Exception {
when(preferences.isAutoBackupEnabled()).thenReturn(false);
Job job = subject.scheduleBootup();
assertThat(job).isNull();
}
use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.
the class BackupJobsTest method shouldScheduleImmediate.
@Test
public void shouldScheduleImmediate() throws Exception {
Job job = subject.scheduleImmediate();
verifyJobScheduled(job, -1, "BROADCAST_INTENT");
}
use of com.firebase.jobdispatcher.Job in project sms-backup-plus by jberkel.
the class BackupJobsTest method shouldScheduleNothingAfterBootForNewScheduler.
@Test
public void shouldScheduleNothingAfterBootForNewScheduler() throws Exception {
when(preferences.isAutoBackupEnabled()).thenReturn(true);
when(preferences.isUseOldScheduler()).thenReturn(false);
Job job = subject.scheduleBootup();
assertThat(job).isNull();
}
Aggregations