创建 NFC“标签”没有 NFC 手机的物体?
当 NFC 标签靠近手机附近时,Android操作系统创建一个 NFC 标签 对象并启动前台调度程序。
我的问题是,我没有 NFC 手机,我试图创建自己的 标记 对象并启动一个 Intent,稍后 Android 操作系统会将该 Intent 转移到我的模拟器上的特定应用程序。
是否可以通过代码创建 NFC 标签 对象?
When a NFC tag is brought closer in the vicinity of the phone, Android OS creates a NFC Tag object and starts the foreground dispatcher.
My problem, is that I don't have a NFC phone and I was trying to create my own tag object and start an intent which later on Android OS will take care to divert that intent to a particular app on my emulator.
Is it possible to create a NFC Tag object via code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不,抱歉。没有办法有效地模拟 NFC。我建议您等待此应用程序,直到您获得支持 NFC 的 Android 设备。
No, sorry. There is no way to emulate NFC effectively. I suggest that you wait on this application until you can acquire an NFC-capable Android device.
绝对有可能模仿正在扫描的 NFC 标签。请参阅
http://developer。 android.com/resources/samples/NFCDemo/src/com/example/android/nfc/simulator/FakeTagsActivity.html
为例。该类所在的 NFC 演示示例有些过时,您需要这些库来编译它:http ://code.google.com/p/guava-libraries/,但它应该告诉您需要做什么。
您基本上只需要创建 NDEF 消息,将其指定为 NFC 意图额外 (EXTRA_NDEF_MESSAGES) 并指定意图,例如 ACTION_NDEF_DISCOVERED,然后调用 startActivity(intent)。
it is definitely possible to mimic an NFC tag being scanned. See
http://developer.android.com/resources/samples/NFCDemo/src/com/example/android/nfc/simulator/FakeTagsActivity.html
for an example. The NFC Demo sample that this class is in is somewhat dated and you need these libraries to compile it: http://code.google.com/p/guava-libraries/, but it should show you what you need to do.
You basically just need to create your NDEF message, specify that as an NFC intent extra (EXTRA_NDEF_MESSAGES) and specify the intent, such as ACTION_NDEF_DISCOVERED, and then call startActivity(intent).
@萨娜
如果您在 Windows 系统上进行开发,我建议您查看Open NFC。
其中有一个模拟器工具,可用于模拟 NFC 标签,但唯一的缺点是,模拟的 Android 映像是 Gingerbread 而不是 ICS(他们正在工作,急于求成)。
否则,我也有同样的问题。我想知道拥有 NFC 阅读器手机的人是否可以编写一个简单的代码,该代码将简单地保留标签对象,以便没有 NFC 阅读器的人实际上可以反序列化该对象并用于模拟!
@Sana
If you are developing on a windows system, i suggest you check out Open NFC.
In it is a Simulator tool which can be used to simulate NFC tags, but the only drawback is, the Android image that is emulated is Gingerbread and not ICS (which they are working, with haste is hope).
Otherwise, i have the same problem. I was wondering if someone with an NFC reader phone can write a simple code, which will simply persist the Tag Object so that people without an nfc reader can actually unserialize that object and use to simulate!
您还可以将 NDEF_DISCOVERED IntentFilter 复制为捕获基本相同内容的新 IntentFilter。
将要写入的数据写入二维码的标签中。并扫描它。手机将使用相同的数据打开相同的活动。当您使用实际的 NFC 标签时,它会模拟相同的响应。
You can also duplicate the NDEF_DISCOVERED IntentFilter as a new IntentFilter that catches basicly the same thing.
Write the data you want to write in a tag in a QR code. And scan it. The phone will open the same activity with the same data. It will be kinda emulate the same reponse when you use an actual NFC tag.