Android - application lifecycle service

I am trying to create Servicefor my application that will reconcile Bluetooth connections and data. I want this service life cycle to start and end with Application, but still could have a specific Activitieslisten to the events that occur in this service (in addition, I Activtyshould be able to call special methods Serviceto record data or request connection status).

I started by creating AIDL interfaces for my callbacks and services, but I can't figure out exactly what I'm doing.

What is the best way to do this? Thank.

EDIT . To be clear, I do not need (or do not need) several processes for my application. Now I have no more than one; I just use AIDL, because it's the only way I know of Serviceto communicate with Activity.

+3
source share
1 answer

I sent an answer on a similar topic, as it was today today.

Restful API Service

I think the best way is to make an IntentService and have your activity as a ResultReceiver, so when your service is running with some work, it sends a message back to this activity.

+3
source

Source: https://habr.com/ru/post/1753628/


All Articles