NFC.NET Library for Android

NFC.NET Library for Android demo example
.NET NFC library for Android.
  • uses Android NFC API
  • provides reading, writing and formatting NFC tags
  • provides Android Beam data transfer
  • supports ISO-DEP, NDEF, NFC-A, NFC-B, NFC-F, NFC-V, MIFARE Classic and MIFARE Ultralight tags
  • source code included in registered version
  • royalty free distribution in applications

Library API

	public enum Mode { Reader, ForegroundDispatch, Beam }

	public class NfcError
	{
		public NfcError(string message);
	}

	public class Nfc
	{
		public Nfc(Activity activity, Mode mode);

		public Activity Activity { get; }
		public NfcAdapter Adapter { get; }
		public bool AdapterEnabled { get; }
		public bool BeamEnabled { get; }
		public Mode Mode { get; }
		public PendingIntent PendingIntent { get; }

		public bool Beam(NdefMessage message)
		public bool Beam(Android.Net.Uri uri);
		public bool Beam(Android.Net.Uri[] uris);
		public bool Beam(string fileName);
		public bool Beam(string[] fileNames);
		public void Disable();
		public void Enable(NfcReaderFlags flags = NfcReaderFlags.NfcA);
		public void OnNewIntent(Intent intent);
		public void ShowBeamSettings();
		public void ShowSettings();

		public event EventHandler BeamComplete;
		public event TagDiscoveredEventHandler TagDiscovered;
	}

	public class NfcTag
	{
		public NfcTag(Tag tag);

		public string Id { get; }
		public MifareClassicTag MifareClassicTag { get; }
		public MifareUltralightTag MifareUltralightTag { get; }
		public NdefFormatableTag NdefFormatableTag { get; }
		public NdefTag NdefTag { get; }
		public IsoDepTag IsoDepTag { get; }
		public NfcATag NfcATag { get; }
		public NfcBTag NfcBTag { get; }
		public NfcFTag NfcFTag { get; }
		public NfcVTag NfcVTag { get; }
		public Tag Tag { get; }
		public string[] TechList { get; }

		public string GetId(char separator = ':');
	}

	public class NdefTag
	{
		public NdefTag(Ndef ndef);

		public bool CanMakeReadOnly { get; }
		public bool IsWritable { get; }
		public NdefItem[] Items { get; }
		public int MaxSize { get; }
		public Ndef Ndef { get; }
		public NdefRecord[] Records { get; }
		public Tag Tag { get; }
		public string Type { get; }

		public bool MakeReadOnly();
		public bool Write(NdefMessage message);
		public bool Write(NdefItem item);
		public bool Write(params NdefItem[] items);
	}

	public class NdefItem
	{
		public NdefItem(NdefRecord ndefRecord);

		public string ExternalText { get; }
		public bool IsAbsoluteUri { get; }
		public bool IsEmpty { get; }
		public bool IsExternalType { get; }
		public bool IsMimeMedia { get; }
		public bool IsText { get; }
		public bool IsUnchanged { get; }
		public bool IsUnknown { get; }
		public bool IsUri { get; }
		public bool IsWellKnown { get; }
		public NdefRecord NdefRecord { get; }
		public byte[] Payload { get; }
		public string PayloadUtf8 { get; }
		public string Text { get; }
		public string TextLanguageCode { get; }
		public string TnfDescription { get; }
		public string Uri { get; }

		public static NdefItem CreateApplicationItem(string packageName);
		public static NdefItem CreateExternalItem(string domain, string type, byte[] data);
		public static NdefItem CreateMimeItem(string mimeType, byte[] mimeData);
		public static NdefItem CreateTextItem(string text, string languageCode = "en");
		public static NdefItem CreateUriItem(string uri);
	}

	public class IsoDepTag
	{
		public IsoDepTag(IsoDep isoDep);

		public IsoDep IsoDep { get; }
		public int MaxTransceiveLength { get; }
		public Tag Tag { get; }
		public int Timeout { get; set; }

		public byte[] Transceive(byte[] data);
	}

	public class NfcATag
	{
		public NfcATag(NfcA nfcA);

		public byte[] Atqa { get; }
		public int MaxTransceiveLength { get; }
		public NfcA NfcA { get; }
		public short Sak { get; }
		public Tag Tag { get; }
		public int Timeout { get; set; }

		public byte[] Transceive(byte[] data);
	}

	public class NfcBTag
	{
		public NfcBTag(NfcB nfcB);

		public int MaxTransceiveLength { get; }
		public NfcB NfcB { get; }
		public Tag Tag { get; }

		public byte[] Transceive(byte[] data);
	}

	public class NfcFTag
	{
		public NfcFTag(NfcF nfcF);

		public int MaxTransceiveLength { get; }
		public NfcF NfcF { get; }
		public Tag Tag { get; }
		public int Timeout { get; set; }

		public byte[] Transceive(byte[] data);
	}
	
	public class NfcVTag
	{
		public NfcVTag(NfcV nfcV);

		public int BlockCount { get; }
		public int BlockSize { get; }
		public sbyte DsfId { get; }
		public int Ic { get; }
		public int MaxTransceiveLength { get; }
		public NfcV NfcV { get; }
		public sbyte ResponseFlags { get; }
		public byte[] SystemInformation { get; }
		public Tag Tag { get; }

		public byte[] EasAlarm();
		public byte[] GetInventory();
		public byte[] LockAfi(byte afi);
		public byte[] LockBlock(byte block);
		public byte[] LockDsfid();
		public byte[] LockEas();
		public byte[] ReadBlock(byte block);
		public byte[] ReadBlocks(byte firstBlock, byte blockCount);
		public byte[] ResetEas();
		public byte[] ResetToReady();
		public byte[] Security(byte firstBlock, byte blockCount);
		public byte[] SetEas();
		public byte[] Transceive(byte[] data);
		public byte[] WriteAfi(byte afi);
		public byte[] WriteBlock(byte block, byte[] data);
		public byte[] WriteBlocks(byte firstBlock, byte blockCount, byte[] data);
		public byte[] WriteDsfid(byte dsfid);
	}

	public class MifareClassicTag
	{
		public MifareClassicTag(MifareClassic mifareClassic);

		public static int BlockSize { get; }
		public int BlockCount { get; }
		public int MaxTransceiveLength { get; }
		public MifareClassic MifareClassic { get; }
		public int SectorCount { get; }
		public int Size { get; }
		public Tag Tag { get; }
		public int Timeout { get; set; }
		public MifareClassicType Type { get; }
		public string TypeDescription { get; }

		public byte[] ReadBlock(int blockIndex, byte[] keyA = null, byte[] keyB = null);
		public byte[][] ReadBlocks(byte[] keyA = null, byte[] keyB = null);
		public byte[] ReadData(byte[] keyA = null, byte[] keyB = null);
	}

	public class MifareUltralightTag
	{
		public enum NTag { Unknown, NTag203, NTag210, NTag212, NTag213, NTag215, NTag216 }

		public MifareUltralightTag(MifareUltralight mifareUltralight);

		public static int PageSize { get; }
		public int MaxTransceiveLength { get; }
		public MifareUltralight MifareUltralight { get; }
		public Tag Tag { get; }
		public int Timeout { get; set; }
		public MifareUltralightType Type { get; }
		public string TypeDescription { get; }

		public int PageCount(NTag nTag = NTag.Unknown);
		public byte[] ReadData(NTag nTag = NTag.Unknown);
		public byte[] ReadPage(int pageOffset);
		public byte[][] ReadPages(NTag nTag = NTag.Unknown);
		public byte[] Transceive(byte[] data);
		public void WritePage(int pageOffset, byte[] data);
		public void WritePages(int firstPageOffset, byte[][] data);

		// NTAG commands
		public byte[] GetVersion()
		public byte[] Read(byte address);
		public byte[] FastRead(byte startAddress, byte endAddress);
		public byte[] ReadCounter();
		public byte[] ReadSignature();
	}

	public class NdefFormatableTag
	{
		public NdefFormatableTag(NdefFormatable ndefFormatable);

		public NdefFormatable NdefFormatable { get; }
		public Tag Tag { get; }

		public bool Format();
		public bool FormatReadOnly();
	}
								

Download and order

Order NFC.NET Library $100,- USD (license for one developer)
Order NFC.NET Library multilicense $300,- USD (license for all developers in company)
Order NFC.NET Library year upgrades $50,- USD (registered users only)
Order NFC.NET Library year upgrades multilicense $150,- USD (registered multilicense users only)

Related links