简体   繁体   English

如果未启用android Beam,则不会为android nfc实现调用onNewIntent

[英]onNewIntent is not being called for android nfc implementation without enabling android beam

I have been working on nfc samples for Peer-To-Peer mode. 我一直在为Peer-To-Peer模式开发nfc示例。 I have implemented onResume method in two different way, for initiator mode and target mode as below: 我以两种不同的方式实现了onResume方法,分别用于启动器模式和目标模式,如下所示:

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. 我将一部Android手机作为启动器,将另一部Android手机作为目标,并将它们背对背。 Here, I can listen NFC device detection sound but does not receive any call to onNewIntent on the android phone set as Target Mode. 在这里,我可以收听NFC设备检测到的声音,但是在设置为“目标模式”的android手机上没有收到对onNewIntent任何呼叫。

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 . 如果我从settings启用了Android NFC Beam ,则在Initiator设备上会收到关于Touch to Beam通知。 In this case I get a call to onNewIntent . 在这种情况下,我会调用onNewIntent

Any direction will be helpful. 任何方向都会有所帮助。

Android Beam is Android's only peer-to-peer communication functionality. Android Beam Android唯一的对等通信功能。 So when you disable Android Beam, you device will not be able to send or receive messages over peer-to-peer mode. 因此,当您禁用Android Beam时,您的设备将无法通过对等模式发送或接收消息。 Consequently, onNewIntent (et al) won't fire when putting two phones together if Beam is disabled. 因此,如果禁用Beam,则在将两部手机放在一起时不会触发onNewIntent (et al)。

Android Beam is implemented on top of the NFC Forum's standard peer-to-peer mode protocol stack: Android Beam是在NFC论坛的标准对等模式协议栈之上实现的:

+--------------------------------------------+
| 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.) (您使用的术语“发起者”和“目标”仅在NFCIP-1层上相关。通常,这两个部分都将在NFC设备上实现,而两个NFC设备(会自动达成共识)由谁来承担发起者的角色,以及谁扮演目标角色。)

So, you would typically implement all layers up to SNEP in order to communicate with an Android device that has Beam. 因此,为了与具有Beam的Android设备进行通信,通常需要实现SNEP的所有层。 Windows Phone 8 and Blackberry already implement SNEP for peer-to-peer NDEF data exchange. Windows Phone 8和Blackberry已经为对等NDEF数据交换实现了SNEP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM