0

I have a service which is is responsible to send requests and take responses over network. I am planning to use it also as an API . So other applications on device can bind to it, send requests and take responses.

1-Is this a proper way to provide an API to other apps?

2-Should I use a Messenger or AIDL ? Messenger seems simpler, but network operation can block a request, so using a single queue for requests can be problematic !

3-Is it a good idea to use same service for both network operations and as an API for other apps ? I can create a separate service for API which binds to network service, but this will bring extra message overhead and code complexity !

metdos
  • 13,411
  • 17
  • 77
  • 120

1 Answers1

0

According to me you need to create a service separately that can be used by both of your applications. And you need to use BroadcastReceiver to start your service as and when android system boots. So that any of your application can use that service.

Creating a simple service is the best idea. You need AIDL for that so that you can transfer the data between service and application with ease.

Japan Trivedi
  • 4,445
  • 2
  • 23
  • 44