This is an Android library designed for two-way NFC payments whith Android KitKat devices and the ACR122u USB NFC Reader.
This library requires that you have successfully installed the AndroidKitKatNFCLibrary as well as the custom-serialization library.
See the Prerequisites section in the Readme of the AndroidKitKatNFCLibrary.
The installation of this library is similar to the installation of the AndroidKitKatNFCLibrary.
You can have a look at or check out the SamplePaymentProject to see how you can use this library in your Android application.
If you want to import this library into your own project, there are three important things that you need to add to your project in order for the NFC to work properly. This is also done in 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:
Inside the<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" />
<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.