In order to relay data between two phones, we have to setup bluetooth communication so that two devices can open sockets to send stream data back and forth.
The model we implemented is a server client model. Either phone can be a server and the other will be the client. The server opens a socket and wait for request for connection. Once a request is received and confirmed, the server will close the listening thread and start a connected thread with an open socket to read/write data. For the client side, user will send out connecting request when it is within the range of another device. Once the request is accepted by the server, client can close the connecting thread and send the data through the socket the server provided.
Android developer site has some tutorials guiding through the bluetooth API. I basically just follow the example project and was able to set up a stable bluetooth connection. We have a text field where user can enter data to send. We tested our connection and it seems working fine. Essential bluetooth is just a util class in our application and the main program just need 3 interface:connect, read and write.