是否有可能通过NFC一触式两款Android设备交换数据? [英] Is it possible to with one touch two Android devices exchange data via NFC?

查看:188
本文介绍了是否有可能通过NFC一触式两款Android设备交换数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个应用程序,通过NFC来交换两个设备之间的信息。

I want to create an application to exchange information between 2 devices via NFC.

我知道如何使采用Android束一个移动将信息发送到其他。我不知道的是两款手机如何将数据发送给对方,只需轻轻一按。

I know how to make one mobile send information to the other using 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?

推荐答案

这取决于你想要达到什么Android版(S)使用的是什么:

That depends on what you are trying to achieve and what Android version(s) you are using:

这两种设备可以发送一个 NDEF消息每个无需用户交互。该消息可以不依赖于彼此(也就是它不可能是一个设备发送消息,另一个发送一个回答这个)。你会使用组合 enableForegroundNdefPush() enableForegroundDispatch()来实现这一目标。

Both devices can send one NDEF message each with no user interaction required. The messages cannot depend on each other (i.e. 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.

这两种设备可以(理论上)发送一个 NDEF每触控消息,但用户交互两个设备上(即用户需要触摸梁UI)。此外,该梁UI两台设备上必须触及pretty的多的同时的。否则,用户界面​​束的其它设备上会得到由于接收的NDEF消息打断。因此,该办法是不是真的有用。你会使用组合 setNdefPushMessage *() enableForegroundDispatch()来实现这一目标。

Both devices can (theoretically) send one NDEF message per touch, but user interaction is required on both devices (i.e. the user needs to touch the Beam UI). Moreover the Beam UI on both devices needs to be touched pretty much at the same time. Otherwise, the Beam UI on the other device will get interrupted due to the received NDEF message. Thus, this "solution" is not really usable. You would use a combination of setNdefPushMessage*() and enableForegroundDispatch() to achieve this.

4.4版本开始,Android有两个新的特点:

Starting with version 4.4, Android has two new features:

  • <一个href="http://developer.android.com/reference/android/nfc/NfcAdapter.html#enableReaderMode%28android.app.Activity,%20android.nfc.NfcAdapter.ReaderCallback,%20int,%20android.os.Bundle%29"相对=nofollow> NFC读写器模式和
  • 基于主机卡仿真(HCE)。
  • NFC reader mode and
  • Host-based Card Emulation (HCE).

当你把这些功能(即你有一个HCE对主机卡仿真业务一台设备上,并把第二个设备进入阅读器模式),这两种设备可以相互(真正的双向通信交流),使用ISO 7816-4 APDU的。

When you combine those feature (i.e. 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.

这篇关于是否有可能通过NFC一触式两款Android设备交换数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆