Sunday 6 December 2020

How to read another apps WorkerManager results?

I have an app (PassiveApp) with a BroadcastReceiver like:

class ResponderReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent) { GlobalScope.launch {
        when (intent.action) {
            "ID" -> {
                Log.d(TAG, "Handling ID broadcast")
                WorkManager.getInstance(context).enqueue(
                        OneTimeWorkRequestBuilder<DataSychronizer>().build())
            }
        }
    }
}

Here we can see, that a WorkerManager is started, which loads and synchronizes some data via DataSynchronizer.

I have a second app (ActiveApp), in which I would like to actively send an Intent (towards PassiveApp) with this ID to trigger the above mentioned BroadcastReceviers onReceive() and starts/enqueues the WorkManager.

How can I get the results of the WorkManager (from PassiveApp) back on ActiveApp side?



from How to read another apps WorkerManager results?

No comments:

Post a Comment