Open Image-link from NFC Tag


Question

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?


Answer

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.



Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes