NDefEncoder
com.rvi.application.NDefEncoder · Class · SocialCard 1.0.3
Serialise URI, text, contact and Wi-Fi records into raw NDEF bytes.
When to use it
Section titled “When to use it”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.
Java example
Section titled “Java example”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.
How it works
Section titled “How it works”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.
Related API
Section titled “Related API”NDefEncoder.EncodedValue · NDefMessageCreator · NDefDecoder · TlvEncoder · NDefEncodingException