Skip to content

NDefText

com.rvi.domain.NDefText · Record · SocialCard 1.0.3

A UTF-8 NDEF text record with a language tag.

Supply a nonempty string and a language tag such as en or de-CH. Use this for labels or short notes that you want downstream applications to read as text.

final NDefText label = new NDefText("Mein Portfolio", "de-CH");
final NDefMessage message = new NDefMessageCreator().add(label).build();
System.out.println(new NDefDecoder().decode(message));
Java imports
import com.rvi.application.NDefDecoder;
import com.rvi.application.creator.NDefMessageCreator;
import com.rvi.domain.NDefMessage;
import com.rvi.domain.NDefText;

An accented or non-ASCII character can take multiple bytes. Check the encoded message size before writing longer text.

The constructor checks Unicode and validates the ASCII language tag with Locale.Builder. Its limit is 63 bytes because the NDEF text status byte reserves six bits for the language length. The payload contains this byte, the language and the UTF-8 text.

NDefTextCreator · NDefMessageCreator · TlvEncoder · NDefValueException

Method signatures in the Javadoc · All API types