Question

I have been working on nfc samples for Peer-To-Peer mode. I have implemented onResume method in two different way, for initiator mode and target mode as below:

For Initiator Mode:

mAdapter.setNdefPushMessage(getTestNdefMessage(), this);

and For Target Mode:

mAdapter.enableForgroundDispatch(this, pendingIntent, null, null);

I made one android phone as an initiator and other as target and put them back to back. Here, I can listen NFC device detection sound but does not receive any call to onNewIntent on the android phone set as Target Mode.

Can anybody help me where I am wrong, in concept OR in implementation. If I enable Android NFC Beam from settings than I get notification on Initiator device for Touch to Beam. In this case I get a call to onNewIntent.

Any direction will be helpful.

Was it helpful?

Solution

Android Beam is Android's only peer-to-peer communication functionality. So when you disable Android Beam, you device will not be able to send or receive messages over peer-to-peer mode. Consequently, onNewIntent (et al) won't fire when putting two phones together if Beam is disabled.

Android Beam is implemented on top of the NFC Forum's standard peer-to-peer mode protocol stack:

+--------------------------------------------+
| Android Beam                               |
+--------------------------------------------+
| NDEF (NFC Data Exchange Format)            |
+--------------------------------------------+
| SNEP (Simple NDEF Exchange Protocol)       |
| (or NDEF Push Protocol (NPP) for backwards |
| compatibility to pre-SNEP Android devices) |
+--------------------------------------------+
| LLCP (Logical Link Control Protocol)       |
+--------------------------------------------+
| NFCIP-1 (ISO/IEC 18092)                    |
+--------------------------------------------+

(The terminology "initiator" and "target" that you use is only relevant on the NFCIP-1 layer. Normally both parts would be implemented on an NFC device and two NFC devices would (somewhat automatically) agree on who takes the initiator role and who takes the target role.)

So, you would typically implement all layers up to SNEP in order to communicate with an Android device that has Beam. Windows Phone 8 and Blackberry already implement SNEP for peer-to-peer NDEF data exchange.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top