简体   繁体   English

是否可以通过一键触摸两个Android设备通过NFC交换数据?

[英]Is it possible to with one touch two Android devices exchange data via NFC?

I want to create an application to exchange information between 2 devices via NFC. 我想创建一个应用程序,通过NFC在两台设备之间交换信息。

I know how to make one mobile send information to the other using Android Beam. 我知道如何使用Android Beam让一个移动设备向另一个移动设备发送信息。 What I don't know is how two phones could send data to each other with just one touch. 我不知道的是两部手机只需轻轻一按就可以相互发送数据。

Is this possible? 这可能吗? If yes, how? 如果有,怎么样?

That depends on what you are trying to achieve and what Android version(s) you are using: 这取决于您要实现的目标以及您正在使用的Android版本:

Both devices with Android < 4.0 Android <4.0的两款设备

Both devices can send one NDEF message each with no user interaction required. 两个设备都可以发送一个 NDEF消息,每个消息都不需要用户交互。 The messages cannot depend on each other (ie it's not possible that one device sends a message and the other one sends an answer to this). 消息不能相互依赖(即,一个设备不可能发送消息而另一个设备发送消息)。 You would use a combination of enableForegroundNdefPush() and enableForegroundDispatch() to achieve this. 您将使用enableForegroundNdefPush()enableForegroundDispatch()来实现此目的。

At least one device with Android < 4.4 至少有一台Android <4.4的设备

Both devices can (theoretically) send one NDEF message per touch, but user interaction is required on both devices (ie the user needs to touch the Beam UI). 两个设备可以(理论上)每次触摸发送一个 NDEF消息,但是两个设备都需要用户交互(即用户需要触摸Beam UI)。 Moreover the Beam UI on both devices needs to be touched pretty much at the same time . 而且两个设备上梁UI需要在同一时间非常感动。 Otherwise, the Beam UI on the other device will get interrupted due to the received NDEF message. 否则,由于收到的NDEF消息,其他设备上的Beam UI将被中断。 Thus, this "solution" is not really usable. 因此,这种“解决方案”并不真正可用。 You would use a combination of setNdefPushMessage*() and enableForegroundDispatch() to achieve this. 您可以使用setNdefPushMessage*()enableForegroundDispatch()来实现此目的。

Both devices with Android 4.4+ 这两款设备均采用Android 4.4+

Starting with version 4.4, Android has two new features: 从4.4版开始,Android有两个新功能:

When you combine those feature (ie you have a HCE on-host card emulation service on one device and put the second device into reader mode), both devices can communicate with each other ( real bi-directional communication ) using ISO 7816-4 APDUs. 当您将这些功能组合在一起时(即您在一台设备上安装了HCE主机卡仿真服务并将第二台设备置于读卡器模式),两台设备可以使用ISO 7816-4 APDU进行相互通信( 实际双向通信 ) 。

This is possible, as explained online here . 这是可能的,因为网上说明这里 There is also an API demo in the API demos provided with the SDK that discusses this. SDK中提供的API演示中还有一个API演示,可以对此进行讨论。

However, keep in mind that NFC has a very small payload size, and you're unlikely to be able to transfer any sizable data using it. 但是,请记住,NFC的有效负载大小非常小,并且您不太可能使用它传输任何可观的数据。 NFC should instead be used to quickly setup bluetooth connections, or another form of wireless transfer like WiFi direct, which can then be used to transfer larger amounts of data. NFC应该用于快速设置蓝牙连接,或者像WiFi direct这样的其他形式的无线传输,然后可以用于传输更大量的数据。

暂无
暂无

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

相关问题 是否可以在没有“ Touch to Beam”屏幕的情况下将NFC数据从一个Android设备传输到另一设备? - Is it possible to transfer NFC data from one Android device to another without the 'Touch to Beam' screen? 如何在Android中使用NFC在两台设备之间发送数据? - How to send data between two devices using NFC in android? 是否可以通过NFC在两个设备之间进行双向通信? - Is it possible to make two-way communication between two devices via NFC? 通过热点在两个Android设备之间进行数据交换 - Data Exchange between two android devices over hotspot 无需云编程即可在一个用户的Android设备之间交换数据 - Exchange data between android devices of one user without cloud programming 是否可以在没有“触摸到光束”屏幕的情况下将NFC文件从一台Android设备传输到另一台? - Is it possible to transfer NFC files from one Android device to another without the 'Touch to Beam' screen? NFC,是否可以在Android和Windows Phone之间交换字符串或字节? - NFC, is it possible to exchange strings or bytes between Android and Windows phone? 在两个具有NFC功能的设备之间进行数据传输,而无需使用Android Beam - Data transfer betweeen two nfc capable devices without using android beam 在 android 设备上检测 NFC - Detecting NFC on android devices NFC-帮助在RC522和Android HCE之间交换数据 - NFC - Help to exchange data between RC522 & Android HCE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM