最近要做一個RFID 相關的項目,具體是關於 13.56MHz 的 NFC 卡的讀寫程序。
1.NFC 常用場景 是 讀卡,寫卡 ,分享內容。 讀寫卡 主要 有兩種 NDEF 讀寫模式 和 非 NDEF 讀寫模式
2. 非NDEF 包含以下 常見數據格式:NfcA/NfcB/NfcF/NfcV/IsoDep/Ndef,意思是如果采用了不同的芯片(選用的標准不同,不同解決方案,) 卡的數據格式不同。
就是 通過 techlist 設置 的選項,獲取 通過 Tag.getTechlist()。
3. 常見的 3種NFC相應程序(每種應用程序的啟動頁就是一個activity),分別對應三種過濾器,那么當一個tag靠近時,nexus s究竟選擇哪種應用程序來處理呢?按照以下的 規 則,該規則成為intent發布系統規則:
activity 1中對intent過濾器設置了Android.nfc.action.NDEF_DISCOVERED的判斷規則;
<intent-filter> <action android:name = "android.nfc.action.NDEF_DISCOVERED" /> <data android:mimeType = "text/plain" /> </intent-filter>
activity 2中對intent過濾器設置了android.nfc.action.TECH_DISCOVERED的判斷規則;
<intent-filter> <action android:name="android.nfc.action.TECH_DISCOVERED" /> </intent-filter> <meta-data android:name="android.nfc.action.TECH_DISCOVERED" android:resource="@xml/filter_nfc" />
activity 3中對intent過濾器設置了android.nfc.action.TAG_DISCOVERED的判斷規則;
<intent-filter> <action android:name="android.nfc.action.TAG_DISCOVERED"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter>
按照優先級:最高的是 activity 1,第二是 activity2,第三是 activity3,當優先級 高的不滿足條件時,才會進行第二個。
NDEF,TECH,TAG, TECH 需要 自己配置額外的xml 過濾。