【发布时间】:2017-11-15 10:05:52
【问题描述】:
我是 android studio 的初学者,但我在 hce 项目中工作。我正在构建一个像钥匙一样工作的应用程序,当我的读者检测到正确的帮助时打开一扇门。我扩展了一个主机 apdu 服务并声明了帮助。我想停止服务或android nfc权限,因为我的应用程序的目的是首先你介绍你的名字和密码。但是我的应用程序中的 nfc 在后台工作,在我输入密码之前我不知道停止 nfc 的方法。
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>
【问题讨论】:
标签: android android-studio service nfc hce