public final class JobConfig extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
addLogger(JobLogger logger)
Add a global logger for the job library, which will be notified about each log statement.
|
static void |
forceApi(JobApi api)
WARNING: You shouldn't call this method.
|
static Clock |
getClock() |
static ExecutorService |
getExecutorService() |
static int |
getJobIdOffset() |
static long |
getJobReschedulePause() |
static boolean |
isAllowSmallerIntervalsForMarshmallow()
Checks whether a smaller interval and flex are allowed for periodic jobs.
|
static boolean |
isApiEnabled(JobApi api) |
static boolean |
isCloseDatabase() |
static boolean |
isForceAllowApi14() |
static boolean |
isForceRtc() |
static boolean |
isLogcatEnabled() |
(package private) static boolean |
isSkipJobReschedule() |
static void |
removeLogger(JobLogger logger)
Remove a global logger.
|
static void |
reset()
Resets all adjustments in the config.
|
static void |
setAllowSmallerIntervalsForMarshmallow(boolean allowSmallerIntervals)
Option to override the minimum period and minimum flex for periodic jobs.
|
static void |
setApiEnabled(JobApi api,
boolean enabled)
WARNING: Please use this method carefully.
|
(package private) static void |
setClock(Clock clock) |
static void |
setCloseDatabase(boolean closeDatabase)
Controls whether the internal database should be closed after each access to clean up
resources.
|
static void |
setExecutorService(ExecutorService executorService)
Overrides the executor service for all parallel execution.
|
static void |
setForceAllowApi14(boolean forceAllowApi14)
On some devices for some reason all broadcast receiver and services are disabled.
|
static void |
setForceRtc(boolean forceRtc) |
static void |
setJobIdOffset(int jobIdOffset)
Adds an offset to the job IDs.
|
static void |
setJobReschedulePause(long pause,
TimeUnit timeUnit)
Overrides the default job reschedule pause.
|
static void |
setLogcatEnabled(boolean enabled)
Global switch to enable or disable printing log messages to Logcat.
|
(package private) static void |
setSkipJobReschedule(boolean skipJobReschedule) |
public static boolean isApiEnabled(@NonNull JobApi api)
public static void setApiEnabled(@NonNull JobApi api, boolean enabled)
api
- The API which should be enabled or disabled.enabled
- Whether the API should be enabled or disabled.public static void forceApi(@NonNull JobApi api)
JobManager
automatically decides which API suits best for a Job
.api
- The JobApi
which will be used for future scheduled JobRequests.public static boolean isAllowSmallerIntervalsForMarshmallow()
false
.public static void setAllowSmallerIntervalsForMarshmallow(boolean allowSmallerIntervals)
allowSmallerIntervals
- Whether a smaller interval and flex than the minimum values are allowed
for periodic jobs are allowed. The default value is false
.public static void setForceAllowApi14(boolean forceAllowApi14)
true
, then this suppresses the JobManagerCreateException
during
the creation of the job manager.forceAllowApi14
- Whether API 14 should be used as fallback in all scenarios. The default
value is false
.public static boolean isForceAllowApi14()
false
.public static boolean addLogger(@NonNull JobLogger logger)
logger
- Your desired logger.true
if the logger was added. Returns false
if the logger was
already added.public static void removeLogger(@NonNull JobLogger logger)
logger
- Your desired logger.addLogger(JobLogger)
public static void setLogcatEnabled(boolean enabled)
enabled
- Whether or not to print all log messages. The default value is true
.public static boolean isLogcatEnabled()
true
.public static long getJobReschedulePause()
public static void setJobReschedulePause(long pause, @NonNull TimeUnit timeUnit)
pause
- The new pause.timeUnit
- The time unit of the pause argument.static boolean isSkipJobReschedule()
static void setSkipJobReschedule(boolean skipJobReschedule)
public static int getJobIdOffset()
public static void setJobIdOffset(int jobIdOffset)
jobIdOffset
- The offset for the very first job ID.public static boolean isForceRtc()
false
and will use the alarm time in SystemClock.elapsedRealtime()
(time since boot, including sleep).public static void setForceRtc(boolean forceRtc)
forceRtc
- Force using the alarm time in System.currentTimeMillis() (wall clock time in UTC). The
default value is false
and will use the alarm time in SystemClock.elapsedRealtime()
(time since boot, including sleep).public static Clock getClock()
static void setClock(Clock clock)
public static ExecutorService getExecutorService()
public static void setExecutorService(@NonNull ExecutorService executorService)
executorService
- The new executor service.public static boolean isCloseDatabase()
false
.public static void setCloseDatabase(boolean closeDatabase)
false
.closeDatabase
- Whether to close the database after each access.public static void reset()