How does WorkManager schedule GET requests to REST API? : <p>I've had a look at the codelab for WorkManager plus some examples on here, but everything in code I have seen is either related to doing work locally on the device or work uploading to the server, not downloading data and responding to the data received. In the developer guidelines it even says, "For example, an app might need to download new resources from the network from time to time," so I thought it would be perfect for this task. My question is if WorkManager can handle the following scenario and if not, what is the proper tool for handling it:</p>

<ol>
<li>Schedule a job that runs once a day in background</li>
<li>The job is to do a data fetch from the REST API (and post it to a LiveData object if possible).</li>
<li>When the data returns, check that it is newer than local data.</li>
<li>Notify the user that new data is available.</li>
</ol>

<p>My worker class looks something like this:</p>

<pre><code>public class MyWorker extends Worker {

@NonNull
@Override
public WorkerResult doWork() {
    lookForNewData();
    return WorkerResult.SUCCESS;
}

public void lookForNewData() {
    MutableLiveData&lt;MyObject&gt; liveData = new MutableLiveData&lt;&gt;();

    liveData.observe(lifeCycleOwner, results -&gt; {
        notifyOnNewData(results);
    })

    APILayer.getInstance().fetchData(searchParams, liveData)
}
</code></pre>

<p>My issue is of course that the LiveData object can't observe because there is no activity or fragment that can be its LifecycleOwner. But even if I used a callback from the API to respond to the data arriving, my worker would already have posted that it was successful  and it probably would not proceed with the callback, right? So I kind of know this approach is totally wrong, but I can't see any code for getting data with WorkManager</p>

<p>Please help with a proper solution and some example code or some links, either with WorkManager if it can handle this kind of work or something else if it is more appropriate.</p>
