你好我想从NFC标签读取。但我得到一个例外。
Hi I am trying to read from NFC Tag. But I am getting an exception.
我已经把这个条件来检测标签?
I have put this condition to detect the tag?
if(NfcAdapter.ACTION_TAG_DISCOVERED != null)
无论这个条件是正确的?
Whether this condition is correct?
要回答你的问题有关code -
To answer you question about the code -
这将永远是真实的 - NfcAdapter.ACTION_TAG_DISCOVERED
是一个恒定值 - 你需要使用:
That will always be true - NfcAdapter.ACTION_TAG_DISCOVERED
is a constant value - you need to use:
getIntent().getAction().equals(NfcAdapter.ACTION_TAG_DISCOVERED)
要进行比较。
不过,这可能无关,与你的例外 -
But, that probably has nothing to do with your exception -
你包括NFC允许在你的Android清单? 你确定你的手机支持NFC,只有两三个就在这个时候支持。 我们就需要从日志堆栈跟踪知道是什么引起的异常