Hallo,
>> Stringurl= "http://example.com";
>> byte[] payload =url.getBytes();
>> NdefRecord ndefRecord = new NdefRecord(NdefRecord.TNF_ABSOLUTE_URI,
>> NdefRecord.RTD_URI, new byte[0], payload);
>
> this works, however I am not sure whether it completely follows the
> NDEF spec.
You are correct. This does not follow the NDEF spec. For
TNF_ABSOLUTE_URI, the type name field needs to be an absolute URI. The
constant NdefRecord.RTD_URI equals to "U", so this is no absolute URI.
> RTD_URI is a well-known type ("U") for record type
> definitions (RTDs), but in this case I would have expected WELL_KNOWN
> as TNF, i.e.
>
> new NdefRecord(
> NdefRecord.TNF_WELL_KNOWN,
> NdefRecord.RTD_URI,
> new byte[0],
> "http://example.com".getBytes())
The payload lacks the identifier code byte in this example.
> If TNF = TNF_ABSOLUTE_URI, i thought that this means that the type
> descriptor is a complete URI (as we know it from XML schema, for
> example). Can someone confirm this (and give an example on when to use
> TNF_ABSOLUTE_URI)?
Correct. TNF_ABSOLUTE_URI means that the type name is an absolute URI.
That URI defines the format of the payload.
An example would be the definition of custom record types for use with
Android.
Android currently implements automatic application launching only for
the well-known URI type, the well-known smart poster type, MIME types
and absolute URI types. The NFC Forum's external type is not (yet)
supported for application triggering.
Thus, you could use an absolute URI type as a replacement for external
types.
new NdefRecord(
NdefRecord.TNF_ABSOLUTE_URI,
"http://nfc-research.at/my-record-scheme".getBytes(),
new byte[0],
payload)
The contents of payload would be defined by the URI
http://nfc-research.at/my-record-scheme. Note however that, as opposed
to an XML schema's URL, the URI
"http://nfc-research.at/my-record-scheme" is just a *name* for that
type. The resource behind the URI does not necessarily need to carry any
information about the type.
br,
Michael
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en