Android:我可以使用 MIME 类型 vnd.bluetooth.ep.oob 过滤 NFC 标签吗?

标签 android bluetooth nfc

我希望我的 Android 应用能够对包含蓝牙 OOB 设置记录的 NFC 标签使用react。我的 list 包含:

<!-- intent filter for matching an NDEF MIME message. -->
<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="application/vnd.bluetooth.ep.oob"/>
</intent-filter>

但是,当我扫描标签时,应用程序没有启动,而是启动了蓝牙连接。有什么办法可以在我的应用程序中处理这些标签吗? (注意:其他 Intent 过滤器,例如,URI 标签可以很好地启动我的应用程序,因此它可能特定于此 MIME 类型。)

最佳答案

因为这是一个 Android Application Record ,它会绕过所有过滤器。 但是,您可以做的是让您的 Activity 实现 Foreground Dispatch

使用它,您可以打开 Activity 以拦截您将在

中收到的 Intent
public void onNewIntent(Intent intent)

当使用 Intent 过滤器方法时,这些 Intent 通过 onResume() 传递,尽管这种情况有所不同。 当应用实际处于 Activity 状态时,使用前台调度时,标签通过 onNewIntent(Intent intent) 传送。

过滤器类型的标签通过 onResume() 传递,因为应用程序是从其他地方启动的。根据标签的不同, Intent 会有不同的操作,您可以在 the Android SDK Docs 阅读所有相关信息。 .

关于Android:我可以使用 MIME 类型 vnd.bluetooth.ep.oob 过滤 NFC 标签吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17506361/

相关文章:

android - 安卓游戏的 Sprite 和动画制作工具

linux - 用于 Linux (Raspberry Pi) 的电话簿访问 (PBAP) 客户端

ios - 使用 CoreBluetooth 检测 Apple Watch

从 ram 清除时,Android 广播不执行

android - 使用 AndroidStudio + gradle + NDK 为 Android 和 Linux 构建库

android - 无法找到作为异步任务的显式 Activity 类

c# - 同时建立多个蓝牙SPP

android - 修改扇区尾部 Mifare Classic 的访问位

android - NFC移动支付说明

android - Nexus 7 支持哪些 NFC 标签? (2012)