Back to project page NFCSocket.
The source code is released under:
Apache License
If you think the Android project NFCSocket listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.chrisplus.nfcsocket; //from w w w . j a v a 2 s .c om import android.os.Bundle; import android.os.Message; import android.os.Messenger; import android.os.RemoteException; public class HCEService extends CustomHostApduService { public static final String TAG = HCEService.class.getSimpleName(); private Messenger serverMessenger; @Override public byte[] processCommandApdu(byte[] commandApdu, Bundle extras) { if (serverMessenger != null) { if (Utils.isSelectAidApdu(commandApdu)) { sendMessage(NfcServerSocket.MSG_SERVER_SELECT_MESSAGE, commandApdu); } else { sendMessage(NfcServerSocket.MSG_SERVER_NORMAL_MESSAGE, commandApdu); } } return null; } @Override public void onDeactivated(int reason) { } @Override public void onRefreshListener(Messenger sMessenger) { serverMessenger = sMessenger; } private void sendMessage(int what, byte[] data) { Message msg = Message.obtain(null, what); Bundle bundle = new Bundle(); bundle.putByteArray(NfcServerSocket.DATA_KEY, data); msg.setData(bundle); msg.replyTo = mMessenger; try { serverMessenger.send(msg); } catch (RemoteException e) { e.printStackTrace(); } } }