Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The first byte of URI payload is the <em>URI identifier code</em>, it is an URI prefix like <code>http://www.</code> or <code>mailto:</code>. You correctly added a byte to the payload length and used an offset of <code>1</code> when copying your URL. You never write this byte so it remains <code>0x00</code> (<em>no prefix</em>), which means you need write the whole URL. This is fine, though you could set it to <code>0x03</code> for a <code>http://</code> prefix if you want to save a few bytes.</p> <p>When reading the payload with <code>msg.getRecords()[0].getPayload()</code>, you need to cut off that byte and add the prefix yourself. I don't think there's a native Android API for this, so you would have to lookup the prefix yourself or try the library mentioned in the other answer.</p> <p>To read the uri correctly you should use something like this:</p> <pre><code>byte[] payload = msg.getRecords()[0].getPayload(); byte identifierCode = payload[0]; String prefix = getUrlPrefix(identifierCode); // you need to implement this one String url = prefix + new String(payload, 1, payload.length -1, Charset.forName("US-ASCII")); getData.execute(url); </code></pre> <p>The method <code>getUrlPrefix</code> could contain a simple switch statement to return a prefix string for an identifier code.</p> <p>You can see a list of codes here: <a href="http://learn.adafruit.com/adafruit-pn532-rfid-nfc/ndef" rel="nofollow">About the NDEF Format</a></p> <blockquote> <pre><code>Value Protocol ----- -------- 0x00 No prepending is done ... the entire URI is contained in the URI Field 0x01 http://www. 0x02 https://www. 0x03 http:// 0x04 https:// 0x05 tel: 0x06 mailto: 0x07 ftp://anonymous:anonymous@ 0x08 ftp://ftp. 0x09 ftps:// 0x0A sftp:// ... </code></pre> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload