Java tutorial
//package com.java2s; import android.nfc.NdefMessage; import android.nfc.NdefRecord; public class Main { public static NdefMessage ndefMessageForVcard(String paramString1, String paramString2) { NdefRecord[] arrayOfNdefRecord = new NdefRecord[1]; arrayOfNdefRecord[0] = createVcard(getContactContents(paramString1, paramString2)); return new NdefMessage(arrayOfNdefRecord); } public static NdefRecord createVcard(String paramString) { return createMime("text/x-vCard", paramString); } private static String getContactContents(String name, String phone) { StringBuilder localStringBuilder = new StringBuilder("BEGIN:VCARD\nVERSION:2.1\nN:;"); localStringBuilder.append(name); localStringBuilder.append(""); localStringBuilder.append(";;;\nFN:"); localStringBuilder.append(""); localStringBuilder.append("\n"); if (!"".equals(phone)) { localStringBuilder.append("TEL;CELL:"); localStringBuilder.append(phone); localStringBuilder.append("\n"); } localStringBuilder.append("END:VCARD"); return localStringBuilder.toString(); } private static NdefRecord createMime(String paramString1, String paramString2) { return new NdefRecord(NdefRecord.TNF_MIME_MEDIA, paramString1.getBytes(), new byte[0], paramString2.getBytes()); } }