Qt NFC 在 Android 系统上
在 Android 上自动启动 NDEF 消息处理程序
Android 支持在触碰 NDEF 标签时自动启动应用程序。
通过在Android 清单文件(AndroidManifest.xml)中提供正确的NFC 意图过滤器,即可实现此功能。
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>启用此 intent-filter 后,一旦触摸 NDEF NFC 标签,应用程序就会自动启动。
注意: 在实际开始目标检测之前,请确保 将所有 GUI 连接到 NFC 类,这一点非常重要 。否则,将无法显示触发应用程序启动的标签中的信息。
注意:必须将 标签接触足够长的时间,以便应用程序启动并读取信息。如果在应用程序启动期间标签脱离,将无法获取任何数据,此时需要再次接触标签。
请参考“带注释的URL”应用程序作为示例。
支持的标签类型
Android 支持的标签类型包括ACTION_NDEF_DISCOVERED、ACTION_TAG_DISCOVERED和ACTION_TECH_DISCOVERED,其TagTechnology为NdefFormatable或Ndef。
如果应用程序在Android 清单文件中注册了其他类型,应用程序虽然会启动,但标签将永远不会被处理。
© 2026 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.