Skip to content

NDefContact

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

A contact encoded as a vCard 4.0 NDEF record.

Supply at least a first or last name. Leave optional email, phone and website fields unset by using the builder, or pass null to the record constructor. Use an HTTP or HTTPS address for the website.

final NDefContact contact = new NDefContact(
"Alex", "Example", "alex@example.com", null, "https://example.com");
final NDefMessage message = new NDefMessageCreator().add(contact).build();
System.out.println(new TlvEncoder().encode(message).length);
Java imports
import com.rvi.application.TlvEncoder;
import com.rvi.application.creator.NDefMessageCreator;
import com.rvi.domain.NDefContact;
import com.rvi.domain.NDefMessage;

vCards can occupy considerably more tag space than a URI. This example measures the stored bytes without NFC hardware.

The record strips surrounding whitespace from fields and stores omitted fields as empty strings. The encoder serialises the supported fields as a text/vcard payload. The decoder accepts the library’s limited vCard shape, so test third-party vCards before assuming they will round-trip.

NDefContactCreator · NDefDecoder · TlvEncoder · NDefValueException

Method signatures in the Javadoc · All API types