Bi-Directional Android Beam

2019-02-10 15:08发布

问题:

Here's what I'm trying to do with 2 Galaxy Nexuses running Android 4.0 with NFC capabilities:

  • Device A and B are in close enough to initiate an Android Beam UI.
  • Device A sends a beam to Device B
  • Device B received beam, does some processing, and then sends a response beam back to device A

I have the initial beam from A -> B working fine but not the communication back. I do want to send something more than just an 'ACk', like a small payload of data. Is there any way to do this over NFC with the current APIs or will I have to look towards WiFi/BT p2p communication?

回答1:

I don't think this is possible unless you pull the devices apart then put them together again and explicitly beam data from Device B to A with the touch to beam UI. You can use NFC to initiate a BT connection though and get the job done.



回答2:

I don't know how but it seems to work. Look at 10min 50sec in this video. They demonstrate peer to peer.

How to NFC on the Android Platform



回答3:

For now, (unfortunately) peer-to-peer mode is only accessible on Android through Android Beam, which can't be used for bi-directional communication. If you want to archieve true bi-directional communication, you can better use reader/writer & card-emulation modes. When emulate a ISO/IEC 14443-4 tag, you can use APDU commands (see ISO/IEC 7816-4) to send bi-directional information.



回答4:

while the two devices are close to each other you can show a toast at B device to ensure it receive the NDEf message



回答5:

I have not tried that myself, but you might be able to acheive a form of bi-directional communication by using one phone in reader/writer mode and the other phone in host based card emulation mode (HCE). See also this thread: NFC reader/writer mode - is it only for tags?.