1

I am a begginer in android studio, but i am working in a hce Project. I am bulding an app that works like a key, and when my reader detects the correct aid open a door. I extends a host apdu Service and declares the aid. I want to stop the service or the android nfc permission, because the propuse of my app is that first you introduce your name and password. But the nfc in my app works in background and idon’t know the way for stop nfc before I put the password.

public class HceService extends HostApduService {

    private static final byte[] SELECT_AID = {0x00, (byte) 0xA4, 0x04, 0x00, 0x07, (byte) 0xBB, 0x52, 0x61, 0x75, 0x6c, 0x0d, 0x0a,};
    private static final byte[] MY_UID = {0x01, 0x02, 0x03, 0x04, (byte) 0x90, 0x00};
    private static final byte[] MY_ERROR = {0x6f, 0x00};






    @Override
    public byte[] processCommandApdu(byte[] apdu, Bundle extras) {
        if (Arrays.equals(SELECT_AID, apdu))
            return MY_UID;
        else return MY_ERROR;

    }

    @Override
    public void onDeactivated(int reason){
    }
}
<service
            android:name=".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>

        <?xml version="1.0" encoding="utf-8"?>
<host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
    android:requireDeviceUnlock="false" >
    <aid-group
        android:category="other">
        <aid-filter android:name="BB5261756c0d0a"/>
    </aid-group>
</host-apdu-service>

1 Answers1

0

You shouldn't stop the NFC transmission for user input. Keep an authorization record for your user and just send all the commands at once. Otherwise, launch the app with the first tap, then have a user authenticate, then tap again.

Sam Edwards
  • 874
  • 8
  • 19