如何测试NFC API? [英] How to test NFC api?

查看:159
本文介绍了如何测试NFC API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台Nexus S采用NFC和Android的API和这样的。

I have a Nexus S with NFC and the Android API and such.

我认为NFC未通过仿真器(?)。

I assume that NFC isn't simulated via the emulator (?).

和我只有一个NFC功能的手机。

And I only have the one NFC enabled phone.

我可以使用RFID卡来测试NFC的应用我做什么呢?或者将我必须得到另一种实现NFC手机?

Can I use RFID cards to test NFC apps I make? Or will I have to get another NFC enabled phone?

感谢

推荐答案

NFC有两种不同的模式:卡读/写和电话的对等通信。测试卡读/写功能在你NFC应用程序通常需要真实卡片。在某些情况下,当卡包含从该卡自动读取由Android操作系统并交付给你的应用程序中意图所谓的NDEF格式的邮件,您可以测试或生成相应的意图自己模仿这一点。 在Android中,对等网络模式对应于Android的光束。接收一个Android束消息在您的应用程序的工作原理相同,从卡检测NDEF消息:机器人提供了NDEF消息的意图,你的应用程序。对于所有的装置和目的,意图是几乎相同的1从含有相同的消息一个卡传递。所以收到Android的光束消息可以使用存储卡(假设卡的内存足够大,可以存储消息)来模拟。 为了测试发送Android的光束消息,我想不出比使用第二部手机的任何其他方式。

NFC has two different modes: card reading/writing and phone peer-to-peer communication. Testing card reading/writing functionality in your NFC app generally requires real cards. In some cases, when the card contains a so-called NDEF-formatted message that is automatically read from the card by the Android OS and delivered to your app in an Intent, you could test or simulate this by generating the corresponding Intent yourself. In Android, peer-to-peer mode corresponds to Android Beam. Receiving an Android beam message in your app works the same as detecting an NDEF message from a card: Android delivers the NDEF message in an Intent to your app. For all means and purposes, the Intent is virtually the same as the one delivered from a card containing the same message. So receiving an Android Beam message can be simulated using a card (assuming the card's memory is large enough to store the message). For testing the sending of an Android Beam message, I cannot think of any other way than using a second phone.

这篇关于如何测试NFC API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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