I have an worker to do a periodical task. and this worker is called in an activity on create. Every time the activity open there is a new instance created and do the same task in same time in multiple times. I called the task like this
task = new PeriodicWorkRequest.Builder(BackgroundTask.class, 1000000, TimeUnit.MILLISECONDS).build();
WorkManager.getInstance().enqueue(task);
how to avoid creating multiple instance? if there is no worker running i need to call the instance on create of the activity.
SingleInstance
in your manifest. – Muirhead