1

My question is, is there a way for two Apps running simultaneously on the same Android device to pass information to each other via a network socket?

There will be two Apps running one will be sending data the other will be receiving the data sent.

The reason i want to send the data, between the Apps, in this way is because the App receiving the data will have to be able to receive data from a network socket at some point so id like to get the ground works of that in place.

So i was wondering if its possible to pass data from one App to another via its own network socket, and if so how would i go about doing it?

user2682570
  • 94
  • 1
  • 2
  • 10
  • I think the best solution is to have an app sending the data and a service receiving it. Take a look on how to create and implement services in java. read [this](http://www.vogella.com/articles/AndroidServices/article.html) and aldo [this](http://stackoverflow.com/questions/4300291/example-communication-between-activity-and-service-using-messaging) – ja_mesa Aug 30 '13 at 13:57
  • Right that's fine but id still need there to be another App that runs the service wouldnt I, and running it with a service would be great but i dont care about that right now. I just want to know if its possible to get an app creating fake data and sending to another app via the devices's own network socket, so if you have an answer to that thatd be great and if you could show me how to that would be even better. – user2682570 Aug 30 '13 at 14:08
  • Have you taken a look at the links I said? There are several kinds of services, local services which is an app service or a system service. You can use any of them for your purpose. If you like us to send code, then we need to see first what you've done so far. Create those app you are talking about then we can recommend/suggest how to make them talk to each other. – ja_mesa Aug 30 '13 at 14:57

1 Answers1

1

Are you aware of the UNIX sockets? We can use UNIX sockets for communicating between apps in the same device. Android supports it.

Helpful links:
1) http://beej.us/guide/bgipc/output/html/multipage/unixsock.html

But I am not aware of how to create UNIX socket in java layer. If you are aware of the JNI then you can create the UNIX socket in C and pass on the data between the Java<->Native layers.

Android supports local sockets:
https://developer.android.com/reference/android/net/LocalSocket.html

Suman
  • 4,221
  • 7
  • 44
  • 64