2011-05-13 119 views
1

我想創建一個可以讀取標籤的應用程序。我複製了NFCDemo代碼,但沒有奏效。我也加了Android NFC:讀取標籤不起作用

<intent-filter> 
    <action android:name="android.nfc.action.NDEF_DISCOVERED" /> 
    <data android:mimeType="mime/type" /> 
</intent-filter> 
<intent-filter> 
    <action android:name="android.nfc.action.TECH_DISCOVERED" /> 
    <meta-data android:name="android.nfc.action.TECH_DISCOVERED" 
    android:resource="@xml/nfc_tech_filter" /> 
</intent-filter> 
<intent-filter> 
    <action android:name="android.nfc.action.TAG_DISCOVERED" /> 
    <category android:name="android.intent.category.DEFAULT"/> 
</intent-filter> 

我的清單文件。

但是應用沒有被調用/當我保持標籤在我的Nexus S.

感謝您的幫助下開了!

回答

1

爲了讓開始時更容易,請刪除所有意圖過濾器,但TAG_DISCOVERED之一。這是最基本的一個。一旦NFC芯片發現NFC標籤,它將通過TAG_DISCOVERED發送出去併發送事件。如果您已將意向過濾器註冊到活動中,則應該看到其中包含您的應用程序的意向選擇器。