I want to execute a task, even after the application is killed using work manager. But, the task is not executed after the app is killed.
workManager = WorkManager.getInstance();
Constraints constraints = new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build();
OneTimeWorkRequest saveData = new OneTimeWorkRequest.Builder(SaveDataWorker.class).setConstraints(constraints).setInitialDelay(10,TimeUnit.SECONDS).build();
workManager.enqueue(saveData);
As I found out, the work manager depends on the device manufacturer. In my case, it is an miui device, which does not allow work manager to work in case the app is killed or rebooted. The work manager worked when I provided the application with "autostart permission".