public void scheduleAsync ( @ NonNull final JobScheduledCallback callback ) { JobPreconditions . checkNotNull ( callback ) ; JobConfig . getExecutorService ( ) . execute ( new Runnable ( ) { @ Override public void run ( ) { try { int jobId = schedule ( ) ; callback . onJobScheduled ( jobId , getTag ( ) , null ) ; } catch ( Exception e ) { callback . onJobScheduled ( JobScheduledCallback . JOB_ID_ERROR , getTag ( ) , e ) ; } } } ) ; }
Helper method to schedule a request on a background thread . This is helpful to avoid IO operations on the main thread . The callback notifies you about the job ID or a possible failure .