Qt NFC 在安卓系统上

在安卓系统上自动启动 NDEF 消息处理程序

Android 提供了在触摸 NDEF 标签时自动启动应用程序的可能性。

这可以通过提供带有适当NFC 意图过滤器Android 清单文件AndroidManifest.xml)来实现。

<intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <data android:mimeType="text/plain"/>
</intent-filter>

启用该意图过滤器后,一旦触摸 NDEF NFC 标签,应用程序就会自动启动。

注意: 在设计应用程序时,一定要确保在实际启动目标检测之前,所有图形用户界面都已连接到 NFC 类。否则将无法显示导致应用程序启动的标签信息。

注意: 触摸标签的时间必须足够长,以便应用程序启动并读取信息。如果在程序启动过程中丢失了标签,将无法获得数据,需要再次触摸标签。

请参阅注释 URL应用程序作为示例。

支持的标签类型

Android 支持的标签类型有ACTION_NDEF_DISCOVEREDACTION_TAG_DISCOVEREDACTION_TECH_DISCOVERED标签技术NdefFormatableNdef

如果应用程序在Android 清单文件中注册了其他类型,应用程序将被启动,但标签将永远不会被处理。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.