4

私は現在、NFCスマートフォン用のAndroidアプリケーション(JAVA)を開発しています。Nfcaタグと通信しようとしていますが、TagLostExceptionを介して送信したコマンドに関係なく取得し続けますtransceive(byte[])。タグはデバイスに適切に接続されています。

重要なコードは次のとおりです。

public void onNewIntent(Intent intent) {
    setIntent(intent);

    tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); // get the tag object for the discovered tag

    nfca = NfcA.get(tag); // try and get the instance for this tag
    if(nfca == null) {
        Alert("tag","the tag is not NfcA");
    } else {
        new Thread(new Runnable() {
            @Override
            public void run() {
                handler.sendEmptyMessage(1); //this will call handleMessage function and handle all error
            }
        }).start();
    }
}

final Handler handler = new Handler() {
    //handles the connection with the tag
    @Override
    public void handleMessage(final Message msgs) {
        // try to connect to the NfcA tag
        try {
            nfca.connect();
        } catch(IOException e) {
            Alert("nfca.connect","cannot open connection ><");
        }
        Toast.makeText(NfcaActivity.this, "tag connected", Toast.LENGTH_LONG).show();

    }
};

try {
    //nfca.setTimeout(3000);
    pageBuffer = nfca.transceive(command);                                                                      
} catch(IOException e) {
    Alert("pageBuffer","cannot perform transceive "+ e.toString());
} catch(Exception e) {
    Alert("exception!", e.toString());
}

私は次のコマンドで試しています:{00 CA 42 08 00}または{00 A4 00 00 02 3F00}、同じ結果が得られます。

これらのコマンドは、PCでスマートカードリーダーとソフトウェアを使用しているときに機能します。スマートカードは空ではありません。

4

1 に答える 1

3

カードにIsoDepも利用可能なテクノロジーがあると思いますか?その場合は、それを使用して接続する必要があります。リストするコマンドの1つは、マスターファイルを選択するためのISO7816-4APDUのように見えます。これは、ISO 14443-4カードで使用されることになっています。これは、まさにIsoDepテクノロジーが表すものです。

于 2013-03-26T14:58:57.947 に答える