问题
I'm trying to start an activity when "tapping" a nfc tag containing a specific mime type. I made a tag with the mime type "text/plain", and added this in the manifest:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<data android:mimeType="text/plain" />
</intent-filter>
If I tap a nfc tag, nothing happen, even if the intent seems right, here is what I see in logs:
03-13 23:36:56.871: INFO/ActivityManager(114): Starting: Intent { act=android.nfc.action.NDEF_DISCOVERED typ=text/plain flg=0x10000000 (has extras) } from pid 192
If I replace the "mime intent-filter" by this one:
<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"/>
the activity is started when a tap the nfc tag. I'm using a Nexus S on 2.3.3.
Any clues?
BR, Patrick
回答1:
I had a similar problem and could solve it by adding a category element:
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<data android:mimeType="text/plain"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
-Oliver
来源:https://stackoverflow.com/questions/5293056/android-nfc-can-we-use-intent-filter-with-mime-type-android-2-3-3