Skip to content

NDefEncoder

com.rvi.application.NDefEncoder · Class · SocialCard 1.0.3

Serialise URI, text, contact and Wi-Fi records into raw NDEF bytes.

Use encodeURI() for one link, encodeURIs() for an ordered list of links, and encode() for a nonempty List<NDefContent>. Encoding runs in memory and needs no connection.

final NDefMessage message = new NDefEncoder().encode(List.of(
new NDefUri("https://rithush.dev"),
new NDefText("My portfolio", "en")));
System.out.println(message.data().length);
Java imports
import com.rvi.application.NDefEncoder;
import com.rvi.domain.NDefMessage;
import com.rvi.domain.NDefText;
import com.rvi.domain.NDefUri;
import java.util.List;

Use NDefMessageCreator when constructing the record list incrementally.

The encoder chooses a record type and payload from each value, sets the first and last record flags, and selects a short or normal payload-length field. It returns a validated NDefMessage. Use TlvEncoder if you need the tag-memory layout.

NDefEncoder.EncodedValue · NDefMessageCreator · NDefDecoder · TlvEncoder · NDefEncodingException

Method signatures in the Javadoc · All API types