25

I'm tooling around with my Nexus S and some MiFare tags and am trying to get together an application that simply reads and displays the ID of a tag. I've looked through the API demo a few times and can't quite get my head around it; I think this is so because the demo includes code for faking tags for developers who don't have access to a real device.

What I need is a tutorial or similar on how to code NFC-based apps for Android, ideally just the required imports and the method that will return the data from a scanned tag.

Does anyone know this off the top of their head?

gonzobrains
  • 7,856
  • 14
  • 81
  • 132
Elomis
  • 532
  • 3
  • 8
  • 18
  • This post may be helpful: [http://stackoverflow.com/questions/5078649/android-nfc-sample-demo-reads-only-fake-information-from-the-tag](http://stackoverflow.com/questions/5078649/android-nfc-sample-demo-reads-only-fake-information-from-the-tag) – fynnbob May 10 '11 at 18:34

3 Answers3

19

Exactly for this.. I did some work.

http://mifareclassicdetectiononandroid.blogspot.com/2011/04/reading-mifare-classic-1k-from-android.html

Hope it helps.

benya
  • 388
  • 3
  • 10
  • 5
    While this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Bill the Lizard Sep 16 '12 at 15:20
12

I wrote an in-depth tutorial on how to get started with NFC here for people who are interested in learning how to integrate NFC with their Android app:

http://www.jessechen.net/blog/how-to-nfc-on-the-android-platform/

Jesse Chen
  • 4,928
  • 1
  • 20
  • 20
9

Here is some resources aimed at entry-level developers:

  1. An NFC boilerplate project for detecting, reading and writing NFC in Android.
  2. The NFC Eclipse plugin for a graphical NDEF editor.
  3. A workshop exercise taking in excess of 1 hour (includes solution)

(shameless plug ;-))

What many tutorials get wrong is that they handle NDEF messages in a low-level way. Rather go for a higher-level library like NDEF Tools for Android than messing around with byte arrays.

ThomasRS
  • 8,215
  • 5
  • 33
  • 48
  • 1
    Thank you for that. All the tutorials I've seen so far work with raw byte arrays, which doesn't seem like it should be necessary for just a "Hello World"-level NFC app. I wonder when Android will get a more pleasant API for this. – Jake Stoeffler Jun 22 '13 at 05:28
  • Thomas, I downloaded 'NDEF Tools for Android' and I see a .jar file, but how would I open that up into 'org.ndeftools.'? I am more accustomed to dragging java files, not dealing with a jar in this case. – David Feb 27 '14 at 10:36
  • Get one of the other downloads, which includes the .java source? – ThomasRS Feb 27 '14 at 13:27