*** CONFIGURAZIONE MANIFEST B4A ***
(Copia questo nel Manifest Editor di B4A)

AddPermission(android.permission.NFC)

' NOTA: AddFeature non esiste in B4A. <uses-feature> non e' necessaria per il funzionamento
' dell'HCE - serve solo come filtro Play Store. Si puo' omettere senza problemi.

' NOTA: AddServiceText e' per servizi B4A-compilati.
' Per una libreria Java esterna usare AddManifestText con il percorso completo della classe.
AddManifestText(
<service
    android:name="com.hce.wrapper.HceManager$HceService"
    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>)

' NOTA: namespace corretto e' schemas.android.com, non android.com
CreateResource(xml, apduservice.xml,
<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:description="B4A HCE Emulator"
    android:requireDeviceUnlock="false">
    <aid-group android:description="NFC Forum Type 4" android:category="other">
        <aid-filter android:name="D2760000850101"/>
    </aid-group>
</host-apdu-service>)

*** CODICE ESEMPIO B4A ***

Sub Process_Globals
    Private nfc As HceManager
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        nfc.Initialize(Me, "nfc")
    End If
    nfc.SetTagText("Mio Messaggio NFC")
End Sub

Sub nfc_OnReaderConnected
    Log("Un lettore NFC ha toccato il telefono!")
End Sub

Sub nfc_OnMessageReceived(Status As String)
    Log("Stato: " & Status)
End Sub
