androidx.work.Configuration Java Examples
The following examples show how to use
androidx.work.Configuration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobProxyWorkManager.java From android-job with Apache License 2.0 | 6 votes |
private WorkManager getWorkManager() { // don't cache the instance, it could change under the hood, e.g. during tests WorkManager workManager; try { workManager = WorkManager.getInstance(mContext); } catch (Throwable t) { workManager = null; } if (workManager == null) { try { WorkManager.initialize(mContext, new Configuration.Builder().build()); workManager = WorkManager.getInstance(mContext); } catch (Throwable ignored) { } CAT.w("WorkManager getInstance() returned null, now: %s", workManager); } return workManager; }
Example #2
Source File: PlatformWorkManagerRule.java From android-job with Apache License 2.0 | 6 votes |
@Override protected void before() { Context context = getContext(); Executor executor = new SynchronousExecutor(); WorkManagerTestInitHelper.initializeTestWorkManager(context, new Configuration.Builder() .setTaskExecutor(executor) .setExecutor(executor) .build()); JobConfig.setJobReschedulePause(0, TimeUnit.MILLISECONDS); JobConfig.setSkipJobReschedule(true); JobConfig.forceApi(JobApi.WORK_MANAGER); mManager = JobManager.create(context); mManager.cancelAll(); }
Example #3
Source File: LttrsApplication.java From lttrs-android with Apache License 2.0 | 5 votes |
@NonNull @Override public Configuration getWorkManagerConfiguration() { //jmap-mua methods regularly use ifInState parameters that require use to have an up to date //local cache. However at the same time this prevents us from launching two modifications at //the same time as the second call would fail with a state miss match. //Therefor all our email modifications (thus far the only thing happening in WorkManager) //are single threaded. LOGGER.info("Create single threaded WorkManager configuration"); return new Configuration.Builder() .setExecutor(Executors.newSingleThreadExecutor()) .build(); }
Example #4
Source File: FlutterUploaderInitializer.java From flutter_uploader with MIT License | 5 votes |
@Override public boolean onCreate() { int maximumConcurrentTask = getMaxConcurrentTaskMetadata(getContext()); WorkManager.initialize( getContext(), new Configuration.Builder() .setExecutor(Executors.newFixedThreadPool(maximumConcurrentTask)) .build()); return true; }
Example #5
Source File: GndApplication.java From ground-android with Apache License 2.0 | 5 votes |
@Override public void onCreate() { if (BuildConfig.DEBUG) { Timber.d("DEBUG build config active; enabling debug tooling"); // Debug bridge for Android applications. Enables network and database debugging for the app // accessible under chrome://inspect in Chrome desktop browser. Must be done before calling // setStrictMode(). Stetho.initializeWithDefaults(this); // Log failures when trying to do work in the UI thread. setStrictMode(); } super.onCreate(); // Enable RxJava assembly stack collection for more useful stack traces. RxJava2Debug.enableRxJava2AssemblyTracking(new String[] {getClass().getPackage().getName()}); // Prevent RxJava from force-quitting on unhandled errors. RxJavaPlugins.setErrorHandler(RxDebug::logEnhancedStackTrace); // Set custom worker factory that allow Workers to use Dagger injection. // TODO(github.com/google/dagger/issues/1183): Remove once Workers support injection. WorkManager.initialize( this, new Configuration.Builder().setWorkerFactory(workerFactory).build()); if (BuildConfig.DEBUG) { Timber.plant(new Timber.DebugTree()); } else { Timber.plant(new CrashReportingTree()); } }
Example #6
Source File: FlutterDownloaderInitializer.java From flutter_downloader with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public boolean onCreate() { int maximumConcurrentTask = getMaxConcurrentTaskMetadata(getContext()); WorkManager.initialize(getContext(), new Configuration.Builder() .setExecutor(Executors.newFixedThreadPool(maximumConcurrentTask)) .build()); return true; }