@SuppressWarnings("WrongConstant")
    @Override
    public void onClick(View v) {
      final Builder builder =
          jobDispatcher
              .newJobBuilder()
              .setTag(form.tag.get())
              .setRecurring(form.recurring.get())
              .setLifetime(form.persistent.get() ? Lifetime.FOREVER : Lifetime.UNTIL_NEXT_BOOT)
              .setService(DemoJobService.class)
              .setReplaceCurrent(form.replaceCurrent.get())
              .setRetryStrategy(
                  jobDispatcher.newRetryStrategy(
                      form.retryStrategy.get(),
                      form.getInitialBackoffSeconds(),
                      form.getMaximumBackoffSeconds()));

      if (form.constrainDeviceCharging.get()) {
        builder.addConstraint(Constraint.DEVICE_CHARGING);
      }
      if (form.constrainOnAnyNetwork.get()) {
        builder.addConstraint(Constraint.ON_ANY_NETWORK);
      }
      if (form.constrainOnUnmeteredNetwork.get()) {
        builder.addConstraint(Constraint.ON_UNMETERED_NETWORK);
      }

      int selectedTriggerPosition = triggerSpinner.getSelectedItemPosition();
      switch (TriggerType.getByPosition(selectedTriggerPosition)) {
        case NOW_TRIGGER:
          builder.setTrigger(Trigger.NOW);
          break;
        case TIMED_TRIGGER:
          builder.setTrigger(
              Trigger.executionWindow(form.getWinStartSeconds(), form.getWinEndSeconds()));
          break;
        case CONTENT_URI_TRIGGER:
          Uri uri = uris[uriSpinner.getSelectedItemPosition()];
          CheckBox notifyForDescendants = (CheckBox) findViewById(R.id.notify_for_descendants);
          int flags =
              notifyForDescendants.isChecked() ? ObservedUri.Flags.FLAG_NOTIFY_FOR_DESCENDANTS : 0;
          ObservedUri observedUri = new ObservedUri(uri, flags);
          builder.setTrigger(Trigger.contentUriTrigger(Arrays.asList(observedUri)));
          break;
        default:
          Log.e(TAG, "Unknown trigger was selected.");
          break;
      }
      Log.i("FJD.JobForm", "scheduling new job");
      jobDispatcher.mustSchedule(builder.build());

      JobFormActivity.this.finish();
    }
An Activity that shows a form UI allowing users to define a custom job.
testapp/src/main/java/com/firebase/jobdispatcher/testapp/JobFormActivity.java