What is the best way for an Android app installed on two devices to communicate with each other? Can the devices connect directly without using text messaging?
The android NSD API is meant to do the exact same thing you are trying to achieve! The example bundled with SDK is self explanatory!
please check:
Android NSD API example