0

Purpose
I need a service thread on the system, which can be bound by my/others apps. The service has to implement an interface and perform tasks like handle the bluetooth connection or similar in a specific reusable manner. In addition a question about the maintainability of the whole thing arises - where i lack of experience

Is it possible to install a service like this on the system? How can it be done without a real membership to a specific application?
Since it is not a really common task i do not found proper documentation (or i simply missed the right tags), so some links could be very useful too!

Ideas
From my research i found following tools which might are suitable:

  • Create an AAR library and include it as module in the projects
  • Provide a OBB extension
  • Create an application which suits my needs and can be started by the other applications (by Intent)

From my understandings none of these can be used really clean in this case and furthermore i dont used any of them before. A small guide through the next rough steps would help me out in case you suggest any of them!

Additional parameter
I would like to hide the sources in case of the use from third party applications which would use my service - dont know if it is possible to lock/separate the two things and use them like proposed, thats why i do not consider this a must have in my case...

UPDATE
AIDL suits my needs. After implementing a tutorial about AIDL i have some remaining questions:

  1. After having a service project and a client project, which are the steps to get it running on the tablet? If i install both as apk's the client still fails to bind to the service. Same if i include the service as module/aar. I dont fully understand the structure of AIDL including the installation process

  2. Is it recommandable to include the service as module in my clients? What happens if i install multiple clients? Do i have make request handling on my service then?

  3. Are shared memory, pipes or similar (which have to be implemented in native?) a real option despite AIDL? What is the preferred way to implement IPC? Or does it depends on the use case?

P.S. Would be great to summarize comments and update together with the answer to my additional questions which i will accept :)

int ermedi_8
  • 171
  • 1
  • 14
  • https://stackoverflow.com/questions/27256324/is-it-possible-to-make-an-apk-with-no-activity – Bhargav Oct 17 '17 at 08:20
  • Ty for the lighting fast response - that thread really coveres a part of my concerns especially [one of the links there](https://stackoverflow.com/questions/10909683/launch-android-application-without-main-activity-and-start-service-on-launching)! So i really have to make a separate lucent application to install my service no matter how ugly that is? Does the communication between the processes only works through intents and hence some basic datatypes then? – int ermedi_8 Oct 17 '17 at 08:37
  • 1
    you can communicate between process using [AIDL](https://developer.android.com/guide/components/aidl.html), if you implement the IBinder interface you can use that to do IPC (Inter-process-communication) – Bhargav Oct 17 '17 at 10:10
  • I tried to implement AIDL, but its not working right now. I am looking for better understanding about AIDL and IPC, since there are many different options and advises i fount about it, which are confusing me a bit. Please check my updated question! – int ermedi_8 Oct 20 '17 at 12:01

0 Answers0