2016-04-04 18 views
0

現在、特定のブロックに数バイトを書き込もうとしています。私のリードコマンドが正常に動作し、私は以下のコードを使用して、私のタグの任意のブロックを読み取ることができています:Android - ISO15693に書き込むタグ

command = new byte[]{ 
      (byte) 0x02, // Flags 
      (byte) 0x23, // Command: Read multiple blocks 
      (byte) 0x09, // First block (offset) 
      (byte) 0x03 // Number of blocks // MAX READ SIZE: 32 blocks:1F 
    }; 
byte[] data = nfcvTag.transceive(command); 

私は以下のコードを記述しようとすると、私のアプリがクラッシュします。

Write = new byte[]{ 
       (byte) 0x02, // Flags 
       (byte) 0x21, // Command: Write 1 blocks 
       (byte) 0x5A, // First block (offset) 
       (byte) 0x41 // Data 
     }; 
    nfcvTag.transceive(Write); 

私はこれをAsyncTaskで行い、java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()例外を取得しています。

ヒント?このタグはSTマイクロエレクトロニクスのM24LR04E-R

答えて

1

です。私はタグがブロックあたり32ビットを持っている間、私はわずか8ビットのデータを書いていた。 3 0x00を追加し、書き込みは成功しました。

Write = new byte[]{ 
      (byte) 0x02, // Flags 
      (byte) 0x21, // Command: Write 1 blocks 
      (byte) 0x5A, // First block (offset) 
      (byte) 0x41, 
      (byte) 0x00, 
      (byte) 0x00, 
      (byte) 0x00 
    }; 
nfcvTag.transceive(Write); 
関連する問題