I was able to send a file using NFC, based on tutorials on the Android developer site. However I'm unable to handle the receiver part.
I follow http://developer.android.com/training/beam-files/receive-files.html for the receiving side and I get the notification that the Beam file transfer was successful on the receiver. When the user clicks this notification, I expect the that my app should be launched.
My receiving activity has the following intent filters:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
<data android:scheme="file" />
</intent-filter>
But my receiving activity never gets called even the file transfer was finished. How can I receive the file in my app?
From Receiving Files from Another Device:
Due to the way how
<data ... />
filters are processed (see Data Test and Data Element), your intent filter translates toSo it must match any of the MIME types and any of the URIs that are given in the data element(s)..
Consequently your intent filter can never match as both, the "image/*" MIME type and the "video/*" MIME type will result in a content URI and not a "file:" URI. Hence, either skipping the URI filter part or chaging the filtered scheme to "content" should do the trick.
or