0

I want to send an unsigned char array from one android application to another continuously in a loop. I know how to send data once. But I need the first app to run in background and send data consistently to another app that performs operation on that data.

Any suggestion will be helpful. Thank you

Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104
Ranjan Das
  • 21
  • 1
  • Possible duplicate of [Data sharing between two applications](https://stackoverflow.com/questions/5745243/data-sharing-between-two-applications) – Hemant Parmar Aug 09 '18 at 12:09
  • @HemantParmar it is not duplicate. User already knows how to share data among two apps. He is looking for available options to run first app in background and send data repeatedly. Please have a look at my answer. One way is to use WorkManager. – Vikasdeep Singh Aug 09 '18 at 12:16

1 Answers1

0

There can be many ways but one is to use WorkManager for this purpose. You can schedule or repeatedly perform operation of sending data from one app to another.

Beauty of WorkManager is that WorkManager might use JobScheduler, Firebase JobDispatcher, or AlarmManager. You don't need to write device logic to figure out what capabilities the device has and choose an appropriate API; instead, you can just hand your task off to WorkManager and let it choose the best option.

Your requirement comes under Recurring tasks:

Usage is like this:

new PeriodicWorkRequest.Builder photoCheckBuilder =
        new PeriodicWorkRequest.Builder(PhotoCheckWorker.class, 12,
                                        TimeUnit.HOURS);
// ...if you want, you can apply constraints to the builder here...

// Create the actual work object:
PeriodicWorkRequest photoCheckWork = photoCheckBuilder.build();
// Then enqueue the recurring task:
WorkManager.getInstance().enqueue(photoCheckWork);
Vikasdeep Singh
  • 20,983
  • 15
  • 78
  • 104