简体   繁体   English

适用于Android虚拟设备(AVD)的NFC标记模拟

[英]NFC tag emulation for Android virtual device (AVD)

Is there any way to develop NFC tag reading/writing applications without an NFC enabled phone? 有没有办法在没有NFC手机的情况下开发NFC标签读/写应用程序? Is there a way to create an AVD which has NFC enabled? 有没有办法创建一个支持NFC的AVD? I have searched and found Open NFC exists, but I cannot find much information about it now. 我搜索过并发现Open NFC存在,但我现在找不到很多关于它的信息。 Is it already obsolete? 它已经过时了吗? Is there any other way to achieve it? 有没有其他方法可以实现它?

Google never implemented support for NFC in the AVD. 谷歌从未在AVD中实现对NFC的支持。 So there is no official support for NFC in the Android device emulator. 因此Android设备模拟器中没有对NFC的官方支持。

Back in the early days of NFC on Android, Inside Secure developed and published the NFC stack "Open NFC". 早在NFC在Android上,Inside Secure开发并发布了NFC堆栈“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. 尽管它的名字,Open NFC并不像它的名字那样开放,主要针对Inside的NFC前端系列。 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. NFC堆栈的一个很好的副作用是它的仿真器集成,类似于诺基亚的NFC虚拟设备支持其S40系列手机的能力。 The public files for the Open NFC project are still available on SourceForge: here . 开放NFC项目的公共文件仍然可以在SourceForge上找到: 这里 However, the project has long been abandoned (probably due to selling their NFC technology to Intel ). 然而,该项目早已被放弃(可能是因为他们将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. Open NFC的最新版本针对Android 4.2.1(适用于Android 4.2.2),因此如果您可以接受该平台,则可以尝试设置该AVD环境。 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 ). 这里有一个循序渐进的指南: 打开NFC模拟器用法 (此处还可以看到缺少的组件: 无法在android平台中加载open-nfc插件 )。

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). 较新的Android版本的NFC堆栈发生了显着变化(如今,整个Android NFC堆栈基于libnfc-nci,最初的目标是Broadcom的NFC控制器,并实现了NFC论坛的NFC控制器接口规范)。 As a consequence, the implementation of Open NFC is no longer compatible to more recent Android versions. 因此,Open NFC的实施不再与更新的Android版本兼容。

Note that there is still ways to do at least some limited testing through code (eg useful for unit tests) by injecting NFC intents. 请注意,通过注入NFC意图,仍然有办法通过代码(例如,对单元测试有用)进行至少一些有限的测试。 See 看到

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 NFC堆栈的内部,您可能需要通过代码来查找您正在瞄准的任何Android版本以模拟正确的信息。

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

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