检查NFC标签靠近 [英] Check if NFC tag is near
问题描述
是否有可能迫使Android的检查,如果NFC标签靠近?我只能够读取标签时,机器人检测到它,我想迫使它来检查代码是否位于靠近在特定时刻
Is it possible to force android to check if an NFC tag is near? I'm only able to read the tag when android detects it, I would like to force it to check if a tag is near at a specific moment
推荐答案
你想要做什么是一般不可能的。但是,如果你可以用一个肮脏的黑客住下面的工作(感谢不确定的行为):
What you want to do is in general not possible. However if you can live with a dirty hack the following will work (thanks to unspecified behaviour):
首先禁用所有支持的标签类型的读者模式。这使NFC子系统到一个干净的状态,例如它确保了NFC控制器必须将标签没有任何联系。
First disable the reader-mode of all supported tag types. This brings the NFC subsystem into a clean state, e.g. it makes sure that the NFC controller will have no connection to the tag.
完成后再次还原阅读器模式。如果标签是在那一刻present您将获得平时发现的行动意图。这可能需要一两秒钟虽然。
Once done restore the reader-mode again. If a tag is present at that moment you will get the usual discovery action as an intent. It may take a second or two though.
阅读器模式的控制是可以使用 NfcAdapter.enableReaderMode
和 NfcAdapter.disableReaderMode
Control of the reader-mode is possible using NfcAdapter.enableReaderMode
and NfcAdapter.disableReaderMode
这篇关于检查NFC标签靠近的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!