Reputation: 57
Is it possible to connect two Android devices into a same wireless network (Access Point) and communicate (e.g. send/receive messages)?
Upvotes: 1
Views: 1417
Reputation: 4550
Yes, you will need to run a server app on one device, and a client app on the other.
You will need to create a Service
running in the background and listening for connections on a port. This service should implement a ServerSocket which can listen for incoming requests and send replies.
You can create a client that will connect to the server using Socket. This can probably be an Activity
with an interface, but be sure to do all of your network connections on a background thread, using eg. AsyncTask
, or else your main UI thread will block and the app may crash.
Upvotes: 1