适用于Android虚拟设备(AVD)的NFC标签仿真 [英] NFC tag emulation for Android virtual device (AVD)

查看:449
本文介绍了适用于Android虚拟设备(AVD)的NFC标签仿真的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果没有启用NFC的电话,是否可以开发NFC标签读取/写入应用程序?有没有办法创建启用了NFC的AVD?我已经搜索并发现Open NFC存在,但是现在找不到关于它的很多信息.已经过时了吗?还有其他方法可以实现吗?

Is there any way to develop NFC tag reading/writing applications without an NFC enabled phone? Is there a way to create an AVD which has NFC enabled? I have searched and found Open NFC exists, but I cannot find much information about it now. Is it already obsolete? Is there any other way to achieve it?

推荐答案

Google从未在AVD中实现对NFC的支持.因此,Android设备模拟器中没有对NFC的官方支持.

Google never implemented support for NFC in the AVD. So there is no official support for NFC in the Android device emulator.

早在Android上使用NFC的初期,Inside Secure就开发并发布了NFC堆栈"Open NFC".尽管有名称,Open NFC并不像其名称所暗示的那样开放,并且主要针对Inside的NFC前端范围. NFC堆栈的一个很好的副作用是其仿真器集成,类似于诺基亚对其S40系列手机提供的NFC虚拟设备支持功能. Open NFC项目的公共文件仍然可以在SourceForge上找到:此处.但是,该项目长期以来一直被放弃(可能是由于

Back in the early days of NFC on Android, Inside Secure developed and published the NFC stack "Open NFC". Despite its name, Open NFC was not as open as its name suggested and was primarily targetting Inside's range of NFC frontends. A nice side-effect of that NFC stack was its emulator integration which resembled the capability of Nokia's NFC virtual device support for their series S40 phones. The public files for the Open NFC project are still available on SourceForge: here. However, the project has long been abandoned (probably due to selling their NFC technology to Intel).

Open NFC的最新版本针对Android 4.2.1(与Android 4.2.2兼容),因此,如果您可以接受该平台,则可以尝试设置该AVD环境.可在此处获得分步指南:打开NFC模拟器用法(另请参阅此处以了解缺少的组件:无法在Android平台上加载open-nfc插件).

The last version of Open NFC targets Android 4.2.1 (worked with Android 4.2.2), so if that platform was acceptable to you, you could try to setup that AVD environment. A step-by-step guide is available here: Open NFC Simulator Usage (also see here for missing components: Failed to load open-nfc addon in android platform).

较新的Android版本上的NFC堆栈发生了显着变化(如今,整个Android NFC堆栈基于libnfc-nci,该库最初以Broadcom的NFC控制器为目标并实现了NFC论坛的NFC控制器接口规范).因此,Open NFC的实现不再与最新的Android版本兼容.

The NFC stack on newer Android versions changed significantly (nowadays, the whole Android NFC stack is based on libnfc-nci which initially targetted Broadcom's NFC controllers and implemented the NFC Forum's NFC Controller Interface specification). As a consequence, the implementation of Open NFC is no longer compatible to more recent Android versions.

请注意,仍然存在通过注入NFC意图通过代码进行至少一些有限测试(例如,对单元测试有用)的方法.见

Note that there is still ways to do at least some limited testing through code (e.g. useful for unit tests) by injecting NFC intents. See

  • How to simulate the tag touch from other application
  • How to mock a Android NFC Tag object for unit testing
  • Is there a way to create an ACTION_NDEF_DISCOVERED intent from code
  • Testing an app by faking NFC tag scan

但是请注意,这些方法依赖于Android NFC堆栈的内部,并且您可能需要遍历针对任何Android版本的代码来模拟正确的信息.

but note that these methods rely on internas of the Android NFC stack and you might need to go through the code for whatever Android version you are targetting to mock the right information.

这篇关于适用于Android虚拟设备(AVD)的NFC标签仿真的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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