I have one periodic job I want to run and it is implemented with the help of Evernote\'s Android Job library.
What I wish to achieve is to updateMyLocation ever 15 mins.
In case of WorkManager, I have added .beginUniqueWork() before .enqueue() and it worked for me.
Constraints myConstraints = new Constraints.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build();
Data.Builder basicWorkerInputDataBuilder = new Data.Builder();
OneTimeWorkRequest otwRequest = new OneTimeWorkRequest.Builder(BasicOneTimeWorker.class)
.setConstraints(myConstraints).addTag("BasicOneTimeWorker")
.setInputData(basicWorkerInputDataBuilder.build());
WorkManager.getInstance().beginUniqueWork("uniqueBasicOneTimeWork",
ExistingWorkPolicy.REPLACE,
otwRequest).enqueue();
The below discussion helped me to find the solution.
https://github.com/googlecodelabs/android-workmanager/issues/16
https://issuetracker.google.com/issues/111569265