Android provides the possibility to automatically launch the application when touching the NDEF tag.
This can be achieved by providing an Android 清单文件 (AndroidManifest.xml) with proper 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>
With this intent-filter enabled, the application will be automatically started once the NDEF NFC tag is touched.
注意: It's important to design your application in such a way that all the GUI is connected to the NFC classes before the target detection is actually started. Otherwise it will be impossible to show the information from the tag that caused application startup.
注意: It's important to touch the tag long enough for the application to start and read the information. If the tag is lost during application startup, no data will be available, and the tag needs to be touched again.
见 注解 URL (统一资源定位符) 应用程序作为范例。
Supported tag types in Android are ACTION_NDEF_DISCOVERED , ACTION_TAG_DISCOVERED and ACTION_TECH_DISCOVERED with TagTechnology NdefFormatable or Ndef .
If the application registers other types in the Android 清单文件 , the application will be started, but the tag will never be processed.