Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android communication between two services

I know that an activity can communicate with a local service using the IBinder interface; I am trying to find a way for communication between two services.

Specifically, I have my main service starting an IntentService to handle file uploads. I want this IntentService to inform back to the main service once it is done uploading, and before it dies.

Any ideas about how this would happen?

like image 731
Chaitanya Avatar asked Apr 21 '11 13:04

Chaitanya


People also ask

How can I communicate between two services in android?

You have to use BroadcastReceiver to receive intents, and when you want to communicate simply make an Intent with appropriate values. This way you should be able to make a 2-way communication between any component.

How do you share data between activity and service?

Primitive Data Types To share primitive data between Activities/Services in an application, use Intent. putExtras(). For passing primitive data that needs to persist use the Preferences storage mechanism. The android.


1 Answers

You have to use BroadcastReceiver to receive intents, and when you want to communicate simply make an Intent with appropriate values.

This way you should be able to make a 2-way communication between any component.

like image 57
Tofeeq Ahmad Avatar answered Oct 20 '22 22:10

Tofeeq Ahmad