I'm using the WorkManager library(version: 1.0.0-alpha12). In my app I'm creating a new process using the below xml line in AndroidManifest.
android:process=":myprocess"
This is how I use the WorkManager:
public static void startCheckStatusWorker() {
WorkManager manager = WorkManager.getInstance();
String uniqueName = "check_status_worker";
PeriodicWorkRequest.Builder builder = new PeriodicWorkRequest.Builder(CheckStatusWorker.class, 1, TimeUnit.DAYS);
builder.setConstraints(new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build());
PeriodicWorkRequest request = builder.build();
manager.enqueueUniquePeriodicWork(uniqueName, ExistingPeriodicWorkPolicy.KEEP, request);
}
But when I call this method from the new process, then the app crashes. This is the exception thrown,
java.lang.IllegalStateException: WorkManager is not initialized properly. The most likely cause is that you disabled WorkManagerInitializer in your manifest but forgot to call WorkManager#initialize in your Application#onCreate or a ContentProvider.
at androidx.work.WorkManager.getInstance(WorkManager.java:139)
If I call the same method, from the normal app process it works well and I don't disable the WorkManagerInitializer in my app manifest as it suggests.
Is there a way to get the WorkManager instance from the new process?
Any suggestion would be appreciated. Thanks.