简体   繁体   中英

Sharing Data Between two Android Apps using Network Sockets

I'm totally new to network sockets so any help is appreciated.

I'd like to know how to setup a network socket on an Android device and use it to pass data generated by an App to another App on the device.

This is because the App receiving the Data will at some point have to be able to receive data from an external source, so I'd like to build in the basics of this before I get to that point.

Any example code etc. would be great and I'll edit my question as I go if required.

I don't think using sockets can solve your problem. Only one app can be active at a given time, and the connection won't work. Unless you create some sort of service, but this approach seems wrong.

I believe you have 2 basic options in front of you:

  1. A server that both apps communicate with.
  2. Writing information to the disk in a globally readable place.

The server option is better IMO.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM