Skip to content

tutcugil/ndef-tools-for-android

 
 

Repository files navigation

Overview

This site hosts a library for Near Field Communication on Android using the NDEF format.

Background

The current (version <= 5.0) Android SDK only comes with a low-level NDEF API which does not expose developers to the full potential of the NDEF format. Rather than sweating over byte arrays, developers should have access to high-level representations.

Features

The most important features are

  • NDEF object representation library (no more byte arrays!)
    • Simple conversion to and from Android SDK low-level equivalent
  • NFC utility library. Abstract activities for:

In other words, this projects helps you to handle dynamic NDEF content at runtime.

NDEF object representation library

So a Message consists of a list of Records in the NDEF standard. Browse the source for an overview.

Creating new NDEF records

Compose an Android Application Record:

AndroidApplicationRecord aar = new AndroidApplicationRecord();
aar.setPackageName("org.ndeftools.boilerplate");

Compose a Mime Record

MimeRecord mimeRecord = new MimeRecord();
mimeRecord.setMimeType("text/plain");
mimeRecord.setData("This is my data".getBytes("UTF-8"));

Create new NDEF message

From above, simply

Message message = new Message(); //  org.ndeftools.Message
message.add(androidApplicationRecord);
message.add(mimeRecord);

or from bytes

byte[] messageBytes = ...; // get your bytes
Message message = Message.parseNdefMessage(messageBytes);

Converting to and from native Android NdefMessage

Use

NdefMessage lowLevel = ...; // get from existing code
Message highLevel = new Message(lowLevel);
// read from high-level records

or

Message highLevel = ...// compose high-level records
NdefMessage lowLevel = highLevel.getNdefMessage();
// .. pass low-level NdefMessage to existing code

NFC utility module

The utility module adds support for interacting with NFC from Android activities. Default implementations are provided in the boilerplate module, for reading and writing and beaming.

A working demo is available in Google Play, search for keywords 'ndef tools demo'. Browse the source for further details.

NFCDemo reworked

If you are familiar with the Android SDK NFCDemo, there is a reworked version using code from this project.

Getting started / tutorial

Visit the getting started overview page or try the beginner Android Tutorial. Alternatively try a tutorial-like workshop (solution included).

NFC Eclipse plugin

For a graphical NDEF editor, try NFC Eclipse plugin. It creates static NDEF content, and so is good for getting to know the NDEF format. Recommended for developers new to NFC.

Tags

Order yourself some NFC tags, and support this project at the same time: Starter packs from RapidNFC. Read more in the NFC Eclipse plugin wiki.

Forum

Please post comments and questions at the NFC developers Google forum group.

Acknowledgements

This project springs out the NFC Tools for Java and NFC Eclipse plugin projects.

News

16th of March 2015: Project migrated from Google Code. Final stats: Approximately 14.8k downloads.
March 17th 2014: Fixed Maven dependency.

History

March 28th 2013: Version 1.2.3 released.
February 5th 2013: Version 1.2.2 released.
January 1st 2013: Version 1.2.1 released.
October 18th 2012: Version 1.2 released.
September 15th 2012: Initial release.

Need help?

If you need professional help with an NFC project, get in touch. Have a look at my apps.

Donate

Chip in to help me buy some more NFC tags and readers and divert time from paid work.

About

NDEF Tools for Android

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%