urbanairship-core/src/main/java/com/urbanairship/job/AndroidJobScheduler.java
@SuppressLint("MissingPermission")
    private void scheduleJob(@NonNull Context context, @NonNull JobInfo jobInfo, int scheduleId, long millisecondsDelay) throws SchedulerException {
        JobScheduler scheduler = getScheduler(context);
        if (scheduler == null) {
            return;
        }

        ComponentName component = new ComponentName(context, AndroidJobService.class);
        android.app.job.JobInfo.Builder builder = new android.app.job.JobInfo.Builder(scheduleId, component)
                .setExtras(jobInfo.toPersistableBundle());

        if (millisecondsDelay > 0) {
            builder.setMinimumLatency(millisecondsDelay);
        }

        if (jobInfo.isPersistent() && ManifestUtils.isPermissionGranted(Manifest.permission.RECEIVE_BOOT_COMPLETED)) {
            builder.setPersisted(true);
        }

        if (jobInfo.isNetworkAccessRequired()) {
            builder.setRequiredNetworkType(android.app.job.JobInfo.NETWORK_TYPE_ANY);
        }

        try {
            if (scheduler.schedule(builder.build()) == JobScheduler.RESULT_FAILURE) {
                throw new SchedulerException("Android JobScheduler failed to schedule job.");
            }

            Logger.verbose("AndroidJobScheduler: Scheduling jobInfo: " + jobInfo + " scheduleId: " + scheduleId);

        } catch (RuntimeException e) {
            throw new SchedulerException("Android JobScheduler failed to schedule job: ", e);
        }
    }
/**
     * Helper method to schedule a jobInfo with the Android JobScheduler.
     *
     * @param context The application context.
     * @param jobInfo The jobInfo.
     * @param scheduleId The schedule ID.
     * @param millisecondsDelay Minimum amount of time in milliseconds to delay the jobInfo.
     * @throws SchedulerException if the schedule fails.
     */
Helper method to schedule a jobInfo with the Android JobScheduler.
@param context The application context.
@param jobInfo The jobInfo.
@param scheduleId The schedule ID.
@param millisecondsDelay Minimum amount of time in milliseconds to delay the jobInfo.
@throws SchedulerException if the schedule fails.
Helper method to schedule a jobInfo with the Android JobScheduler . @param context The application context . @param jobInfo The jobInfo . @param scheduleId The schedule ID . @param millisecondsDelay Minimum amount of time in milliseconds to delay the jobInfo . @throws SchedulerException if the schedule fails .
@SuppressLint("MissingPermission")
    private void scheduleJob(@NonNull Context context, @NonNull JobInfo jobInfo, int scheduleId, long millisecondsDelay) throws SchedulerException {
        JobScheduler scheduler = getScheduler(context);
        if (scheduler == null) {
            return;
        }
        ComponentName component = new ComponentName(context, AndroidJobService.class);
        android.app.job.JobInfo.Builder builder = new android.app.job.JobInfo.Builder(scheduleId, component)
                .setExtras(jobInfo.toPersistableBundle());
        if (millisecondsDelay > 0) {
            builder.setMinimumLatency(millisecondsDelay);
        }
        if (jobInfo.isPersistent() && ManifestUtils.isPermissionGranted(Manifest.permission.RECEIVE_BOOT_COMPLETED)) {
            builder.setPersisted(true);
        }
        if (jobInfo.isNetworkAccessRequired()) {
            builder.setRequiredNetworkType(android.app.job.JobInfo.NETWORK_TYPE_ANY);
        }
        try {
            if (scheduler.schedule(builder.build()) == JobScheduler.RESULT_FAILURE) {
                throw new SchedulerException("Android JobScheduler failed to schedule job.");
            }
            Logger.verbose("AndroidJobScheduler: Scheduling jobInfo: " + jobInfo + " scheduleId: " + scheduleId);
        } catch (RuntimeException e) {
            throw new SchedulerException("Android JobScheduler failed to schedule job: ", e);
        }
    }
@ SuppressLint ( "MissingPermission" ) private void scheduleJob ( @ NonNull Context context , @ NonNull JobInfo jobInfo , int scheduleId , long millisecondsDelay ) throws SchedulerException { JobScheduler scheduler = getScheduler ( context ) ; if ( scheduler == null ) { return ; } ComponentName component = new ComponentName ( context , AndroidJobService . class ) ; android . app . job . JobInfo . Builder builder = new android . app . job . JobInfo . Builder ( scheduleId , component ) . setExtras ( jobInfo . toPersistableBundle ( ) ) ; if ( millisecondsDelay > 0 ) { builder . setMinimumLatency ( millisecondsDelay ) ; } if ( jobInfo . isPersistent ( ) && ManifestUtils . isPermissionGranted ( Manifest . permission . RECEIVE_BOOT_COMPLETED ) ) { builder . setPersisted ( true ) ; } if ( jobInfo . isNetworkAccessRequired ( ) ) { builder . setRequiredNetworkType ( android . app . job . JobInfo . NETWORK_TYPE_ANY ) ; } try { if ( scheduler . schedule ( builder . build ( ) ) == JobScheduler . RESULT_FAILURE ) { throw new SchedulerException ( "Android JobScheduler failed to schedule job." ) ; } Logger . verbose ( "AndroidJobScheduler: Scheduling jobInfo: " + jobInfo + " scheduleId: " + scheduleId ) ; } catch ( RuntimeException e ) { throw new SchedulerException ( "Android JobScheduler failed to schedule job: " , e ) ; } }
Helper method to schedule a jobInfo with the Android JobScheduler.
Helper method to schedule a jobInfo with the Android JobScheduler .