2

I'd like to send and trigger opening of an HTML page via NFC/Android Beam in the way that's compatible with stock Android devices (and ideally any NFC-compliant smartphone).

I'd like this to work off-line, so I'm trying to send actual HTML payload rather than an HTTP URL.

I've tried sending data:text/html,… URL, but unfortunately Android doesn't open these URLs in a browser. It shows it in "New tag collected" app without ability to take any action.

I've tried sending text/html MIME payload, but again it shows as unclickable "text/html" entry in "New tag collected" app.

I'm using this example with this modification:

    @Override
    public NdefMessage createNdefMessage(NfcEvent event) {        
        return new NdefMessage(
                NdefRecord.createMime("text/html", "Hello".getBytes()),
                NdefRecord.createUri("data:text/html,Hello")
        );                  
    }

Screenshot

How can I send text/html file that Android will automatically open in a browser?

Kornel
  • 97,764
  • 37
  • 219
  • 309
  • Have you tried just one of those records, rather than both simultaneously? – CommonsWare Nov 16 '13 at 14:14
  • Yes, I've tried them individually. Effect is the same. Oddly, when I send image/jpeg this way I also get this crappy tag-detected screen, but Gallery app can send images seamlessly. Is there a special API or message type I should be using? – Kornel Nov 16 '13 at 14:22
  • Not that I am aware of, though I haven't tried this specific scenario. It's a good idea, though -- I'll have to budget some time to run some tests. Particularly sometime when I'm not on an airplane. :-) – CommonsWare Nov 16 '13 at 14:24
  • 1
    FWIW, at least on Android 4.4, I cannot get anything to open automatically, if the "new tag collected" piece is what winds up responding to the tag. Even using the URL is insufficient to open up a browser, at least not Chrome. Hence, I don't think this is a problem peculiar to trying to send the data offline. – CommonsWare Nov 18 '13 at 19:03

0 Answers0