Remote app to respond the client request through IPC
Remote app is responsible for processing the client app request and send back the respective response. App is not supposed to be running to process the request, it should only be installed on same device Client app is running on.
It incorporates the use of Service, Messanger and Handler classes to keep going the communication seemlessly. For message echoing, it makes the server call to postman-echo API which in returns echo back the message in json wrapper.
It should be installed before the client app and internet connection is required for message echoing part.
- Use the
IntentServiceto receive the input at Remote app end and send back the result via PendingIntent or Messanger or Broadcast Intent or ResultReceiver. - Use the
Broadcast Intentto send & receive the data.Intent Filterscan be defined by each application based on the type of data they receive. - Use
Content Providerat Client app to store the data & access them at Remote App viaContentResolver. - We can directly access the activity of other application if they are runnning in same process, hence we can user the Intent to send the data back and forth.
Solution implemented in this app is by using Bound Services which optimizes the implementation as compared to above solutions: You don't need to declare any Intent Filters to receive data, you wake the Remote app only when Client app needs to communicate and sends backs to sleep once Client app is done with communication. Also, you don't need to worry about in which process these apps are running as we are not directly accessing their classes/methods. We are not storing the data at any common place like Content Provider, hence it removes the data security concern.