How to send data between two devices using NFC in android?

Hi I am developing a simple app using NFC in android. NFC api is available in version 2.3.3 and higher. This is the documentation and simple demo code for communicating with an NFC enabled Android device with an NFC tag. I find sample code from the link below.

http://developer.android.com/resources/samples/NFCDemo/index.html

And I didn't find any useful code for communication between two Android devices. Please provide me with an example of how we can communicate with p2p between two android devices.

Thank you in advance

+3


source to share


2 answers


Sorry if I have to disappoint you, but active p2p communication between two Android devices is not possible at the moment. Although you can push NDEF messages between two devices using p2p. It works like this. One of the phones logs an NDEF message to be pressed and as soon as the other phone enters the other phone's field, this message is exchanged. In ICS, a Beam UI appears on the sending phone to ask the user to confirm sending the message. It all looks more like one of the phones is emulating a tag, the difference is that the LLCP protocol is used for communication.

If this behavior fits your use case, you can find a good explanation on how to use this in this blog post:

http://www.jessechen.net/blog/how-to-nfc-on-the-android-platform/



and also have a look at the NFCAdapter doc (enableForegroundNdefPush and enableForegroundDispatch)

http://developer.android.com/reference/android/nfc/NfcAdapter.html#enableForegroundNdefPush%28android.app.Activity,%20android.nfc.NdefMessage%29

+10


source


This is possible with Android version 4.x with the Beam service. More details



+3


source







All Articles