2

I have a NFC-Tag (FeliCa), where I store a URL to an image. (something like https://www.google.de/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png for example). This Tag is emulated by a ACR1252U USB NFC-Reader, but for any Android smartphone it behaves like any real physical tag. When I approach my Android 4.4-Smartphone, to the (emulated) tag, it automatically opens my Browser-App, and browses to image-link.

So far so good.

However my goal is, that the Android smartphone does not open the image in the browser, but saves the image to the storage and / or displays it in the image-gallery app of the Android phone. I want to achieve this, with as few steps as possible.

For sure there has to be some prompt for the user "Do you want to save that image" or something. But how can I achieve this? How do I have to store the image-link on the nfc-tag, that the image opens in the gallery instead the browser?

2

No, there is no such option that you can set on the NFC tag to force Android to immediately store the image or show it in the gallery app. The reason for this is that you only store a URL on the tag. Before actually opening the URL, Android does not even know the data type behind the URL (i.e. "this is an image"). In fact URLs do not have that concept of a data type, they just refer to some storage location. Consequently, Android can only open an app that is registered for that URL (or URLs in general), which is typically a web browser.

What you could do:

  1. If you have control over the server side, you might want to try to force the image to be downloaded from the server. You could do this by setting a Content-Disposition header when the image is requested from the server:

    Content-Disposition: attachment; filename="googlelogo_color_272x92dp.png"
    
  2. If the image fits on your emulated tag, you could try to embed it into a MIME type record instead of passing a URL to the image. On many Android devices, image MIME type records should be opened in the standard Tags app by default (see Read NFC tag without specific application?). However, I've never tested how well this works (or if the image is actually displayed at all). See Picture on nfc tags on how such a MIME type record could be created with Android code.

  • Thanks. I went for solution 1. The URL opens an HTML- site, that contains the image. A javascript than asks the user to save the image. If the user confirms it, the image will be opened in the image gallery. – Michael B Nov 22 '15 at 19:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.