Skip to content

jetonmemeti/android-kitkat-nfc-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

android-kitkat-nfc-library

This is an Android library which offers NFC peer-to-peer functionality for Android KitKat devices irrespective of the build-in NFC controller (Broadcom or NXP).
In addition to the Android NFC functionality, this library allows sending larger messages by providing message fragmentation and reassembly. It also makes it possible to use the two-way NFC (Host-based Card Emulation) with NXP devices, since it covers connection disruptions appropriately.
Furthermore, it also supports the ACR122u USB NFC Reader, which can be attached to an Android KitKat device. The user can't decide which NFC controller to use (the interal/build-in or the external ACR122u one). If the ACR122u is plugged in, it will automatically be used once the NfcInitiator is initialized.

Prerequisites:

Installation Guidelines:

  • Install two third-party libraries to your local maven repository (read here how to install 3rd party JARs).
    • You need the maven-android-sdk-deployer. Follow the instructions there - only platform 4.4 needs to be installed. (This library requires the properties-maven-plugin to be installed to your local maven repository. Otherwise, the installation of maven-android-sdk-deployer will fail.)
    • You also need the Android Library for the ACR122u, even if you do not plan to use it in your application. You can download the JAR on the ACS website or from this git repository here.
  • Clone this git repository.
  • In Eclipse go to File --> Import --> Maven --> Existing Maven Project. In the appearing dialog under Root Directory enter the path to the checked out project in your git repository.
  • Select the project AndroidKitKatNFCLibrary and click on Finish.
  • Run mvn install on the root folder of this project to install it to your local maven repository. Now you can use this library in your project by adding its groupId, artifactId, and version (see pom.xml) to the POM of your project.
How to Use: ----------- You can have a look at or check out the AndroidNFCPaymentLibrary to see how you can use this library.

If you want to import this library into your own Android project - without using the AndroidNFCPaymentLibrary - there are three important things that you need to add to your project in order for the NFC to work properly. (See for example the SamplePaymentProject.)

  • Copy the file apduservice.xml to <project root folder>\res\xml\.
  • In <project root folder>\res\values\strings.xml add the following:
    <!-- APDU SERVICE -->
    <string name="aiddescription">ch.uzh.csg.nfclib</string>
    <string name="servicedesc">Android KitKat NFC Library</string>
  • In the AndroidManifest.xml add the following:
    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" />
    <uses-feature android:name="android.hardware.nfc" android:required="true" />
    <uses-permission android:name="android.permission.NFC" />
    Inside the <application> tag add:
    <service android:name="ch.uzh.csg.nfclib.HostApduServiceNfcLib" android:exported="true" android:permission="android.permission.BIND_NFC_SERVICE">
    <intent-filter>
    <action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />
    </intent-filter>
    <meta-data android:name="android.nfc.cardemulation.host_apdu_service" android:resource="@xml/apduservice" />
    </service>

Once this is done, you can use this library in your project by adding its groupId, artifactId, and version (see pom.xml) to the POM of your project.

About

This is an Android library which offers NFC peer-to-peer functionality for Android KitKat devices.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages