This API is for interaction with the External NFC Service app found in Google Play.
The External NFC Service app provides NFC-functionality along the lines of native Android NFC for external NFC readers connected via USB.
Projects using this library will benefit from:
- External NFC reader management and interaction
- Parallell use of external and/or internal NFC (i.e. in the same activity, both enabled at the same time)
- Support for both tags and Android devices (Host Card Emulation), simultaneously
- Use of using Andriod built-in (native) types (Ndef, MifareUltralight, IsoDep, etc).
As this project very much simplifies implementation for use-cases requiring external NFC readers, it saves a lot of development time (2-8 weeks depending on use-case and previous knowledge).
This repository contains source code for
- An Android library project (the actual API), and
- Demo client apps demonstrating actual usage
- Basic client app
- NXP API client for MIFARE SDK
- Web Kiosk client with javascript bindings
There is also a Host Card Emulation client app for use with the Basic client app.
The API defines
- broadcast actions
- service start / stop and status
- reader open / close and status
- tag connect / disconnect
- 'extras' objects for interaction with readers
- disable beeps
- display text
- configure NFC tech types (PICC)
- enable/disable LEDs
- run custom commands
- and more..
- abstract activities for interaction with built-in and external NFC (simultaneously)
- these currently depend on the NDEF Tools for Android project.
- Programmatically start and stop the service (see methods startService() and stopService() in the NfcExternalDetectorActivity class in for an example).
Note that tag interaction is performed via the native NFC classes and so these are not included in the API itself. These native NFC classes are present even on non-NFC devices.
Currently the ACS readers
- ACR 122U (API)
- ACR 1222L (API)
- ACR 1251U (API)
- ACR 1252U (API)
- ACR 1255U-J1 (API) - NOTE: bluetooth support in beta
- ACR 1281U-C1 (API)
- ACR 1283L (API)
are supported and must be connected to your Android device via an On-The-Go (OTG) USB cable.
Additional ACR readers might work depending on their command set, however custom reader commands will (like LED, beep etc) will not be available.
The following tags are supported by the service
- Mifare Ultralight familiy
- Mifare Ultralight
- NTAG 21x with FAST READ
- Mifare Classic and friends
- Not recommended due to security and compatibility issues
- Desfire EV1 tags
- Host Card Emulation - interaction with Android devices.
The readers can for the most part can be enabled for all tag types at the same time, including Host Card Emulation.
Please note:
- Some readers only support a subset of the above tags
- For ACR 122U the Mifare Classic does not work well.
- No built-in NDEF support for Desfire EV1 cards (let me know it this is interesting to you).
Configuration options
- assume all NTAG21x Mifare Ultralight targets. This improves read speed, particullary for the tags which have legacy equivalents, like NTAG 210 and 213
- read only tag UIDs, ignore other tag data. This improves read speed.
- read NDEF data automatically
- read UID for Desfire EV1 targets automatically
Please report any issues to [email protected].
Note that not all Android devices actually have an USB hub, in which case no USB devices work.
Does the ACR reader not light up when connected to your device, even after the service asks for USB permissions? The ACR reader shuts down if there is not enough battery, so try charging your battery more, or connect external power.
If you are using external power, be aware that the connection order (device, reader, power) might be important. Known symptom:
- Seeing an USB permissions window that disappears rather quickly.
There is quite a few types of tags out there, and if your tag type is not recognized, please let me know. If the tag does not register at all, make sure that auto polling is configured, and that the right protocols are enabled. Use the below utility apps for tweaking your reader settings.
You might be interested in
- ACR 1222L USB NFC Reader Utils
- ACR 122 USB NFC Reader Utils
- ACR 1251 USB NFC Reader Utils
- ACR 1252 USB NFC Reader Utils
- ACR 1281 USB NFC Reader Utils
for configuration of your reader. Approximately the same configuration options are available using this API.
Please email feature requests to [email protected].
Get in touch for bulk and/or offline distribution. A library jar is also available on request, simplifying distribution of your own app(s). Source code is also an option.
If you need professional, cost-efficient assistance with an NFC project, get in touch. I also do
- Desfire EV1 tech (with encryption) - example app
- WebView-based apps, either visiting ULRs and/or interaction over Javascript.
- NFC-initiated wifi connectivity
- More advanced Host Card Emulation (HCE) for Android
- NFC development tools
- NFC supplimented with QR codes
- Smartcard-related workflows and integrations over ESB or BPM modelling
- Custom binary formats for NDEF or raw tag data - fit your data for minimal read/write time and best form factor selection
- Apache Cordova plugins for Android
Feel free to connect with me on LinkedIn, see also my Github page.