enableForegroundDispatch 用于从 NFC 标签启动的活动

问题描述 投票:0回答:0

我用

NdefRecord.createApplicationRecord()
写一个NFC标签。

我尝试在读取 NFC 标签时获取文本,它在应用程序启动时起作用

if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())) {

但是当标签启动应用程序时,

intent.getAction()
等于
android.intent.action.MAIN
而不是
android.nfc.action.TECH_DISCOVERED

我认为

NfcAdapter.enableForegroundDispatch()
中的
onResume()
在这种情况下还不能读取NFC标签,如何解决这个问题?

谢谢

java android nfc
© www.soinside.com 2019 - 2024. All rights reserved.