public void setEnableScheduledScanJobs ( boolean enabled ) { if ( isAnyConsumerBound ( ) ) { LogManager . e ( TAG , "ScanJob may not be configured because a consumer is" + " already bound." ) ; throw new IllegalStateException ( "Method must be called before calling bind()" ) ; } if ( enabled && android . os . Build . VERSION . SDK_INT < Build . VERSION_CODES . LOLLIPOP ) { LogManager . e ( TAG , "ScanJob may not be configured because JobScheduler is not" + " availble prior to Android 5.0" ) ; return ; } if ( ! enabled && android . os . Build . VERSION . SDK_INT >= Build . VERSION_CODES . O ) { LogManager . w ( TAG , "Disabling ScanJobs on Android 8+ may disable delivery of " + "beacon callbacks in the background unless a foreground service is active." ) ; } if ( ! enabled && android . os . Build . VERSION . SDK_INT >= Build . VERSION_CODES . LOLLIPOP ) { ScanJobScheduler . getInstance ( ) . cancelSchedule ( mContext ) ; } mScheduledScanJobsEnabled = enabled ; }
Configures using a ScanJob run with the JobScheduler to perform scans rather than using a long - running BeaconService to do so .