Skip to content

NDefMessageCreator

com.rvi.application.creator.NDefMessageCreator · Class · SocialCard 1.0.3

Build a single NDEF message from an ordered list of typed records.

Call add() once per record, then build(). Put the URI first when the main purpose of the tag is to open a link. Use a fresh builder when composing a separate message.

final NDefMessage message = new NDefMessageCreator()
.add(new NDefUri("https://rithush.dev"))
.add(new NDefText("My portfolio", "en"))
.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;
import com.rvi.domain.NDefUri;

The decoder returns the link followed by the text. Which records a phone acts on is up to its NFC software.

add() rejects null. The builder keeps entries in insertion order and delegates serialization to NDefEncoder at build time. At least one record is required. A previously built message keeps its own bytes if the builder receives more records.

NDefContent · NDefMessage · NDefEncoder

Method signatures in the Javadoc · All API types