0
저는 android studio의 초보자입니다.하지만 저는 hce 프로젝트에서 일하고 있습니다. 나는 키처럼 작동하는 앱에 불을 붙이고 있으며, 독자가 올바른 원조가 문을 열었을 때이를 감지합니다. 호스트 apdu 서비스를 연장하고 원조를 선언합니다. 내 앱의 프로 복스가 처음으로 내 이름과 비밀번호를 소개하기 때문에 서비스 또는 android nfc 권한을 중지하고 싶습니다. 하지만 백그라운드에서 작동하는 애플 리케이션에서 nfc 및 idon't 비밀 번호를 넣어 전에 nfc 중지 방법을 알고.HostapduService를 시작하고 중지하는 방법
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>
또한 https://stackoverflow.com/q/25176181/2425802를 확인하십시오. –