jantox
jantox

Reputation: 2185

Pass data from activity to service in android that are in different applications

I know you can use Intent when passing data. My question is, I want to call a Service in another application from my Activity.

Here is the example scenario...

APP1:LoginActivity --> pass parameters to APP2, call APP2:VerifyLogin --> result goes back to APP1:LoginActivity

is there a way to do this?

Upvotes: 2

Views: 147

Answers (1)

Moin Ahmed
Moin Ahmed

Reputation: 2898

1) If you own both the applications, it would be better to call the APP2's service from the APP1 itself (i.e. define service in APP1 instead of the APP2).

But if there is a case to communicate between two APP, you can implement the different strategy to meet them as listed below.

2) Make use of Broadcast Receiver:

Register a Broadcast Receiver in the APP2 and send a broadcast message from the APP1 with the required parameters, and do the same to communicate from the APP2 to APP1 using Broadcast Receiver mechanism.

3) Make use of Android Interface Definition Language (AIDL),

Google Doc says :

It allows you to define the programming interface that both the client and service agree upon in order to communicate with each other using interprocess communication (IPC).

I think this will enable you to communicate between two applications by defining some communication protocol.

Example : Here is a nice TUTORIAL which will help you to understand how it actually works.

Hope this will give you some hint about solving your problem.

Upvotes: 1

Related Questions