android demo学习(2)

来源:互联网 发布:mac如何安装zip文件 编辑:程序博客网 时间:2024/05/29 17:35
转载请注明出处:http://blog.csdn.net/awebkit

我们今天学习一下NFCDemo

FakeTagsActivity发布Tag,TagViewer处理Tag,流程简单,不说了

说一下MockNdefMessages里面的结构

以paint text为例

    /**     * A plain text tag in english.     */    public static final byte[] ENGLISH_PLAIN_TEXT =        new byte[] {(byte) 0xd1/*flags(5)+tnf(3)*/, (byte) 0x01/*type length*/, (byte) 0x1c/*payload length*/, (byte) 0x54/*'T'*/, (byte) 0x02, (byte) 0x65,            (byte) 0x6e, (byte) 0x53/*'S'*/, (byte) 0x6f, (byte) 0x6d, (byte) 0x65, (byte) 0x20,            (byte) 0x72, (byte) 0x61, (byte) 0x6e, (byte) 0x64, (byte) 0x6f, (byte) 0x6d,            (byte) 0x20, (byte) 0x65, (byte) 0x6e, (byte) 0x67, (byte) 0x6c, (byte) 0x69,            (byte) 0x73, (byte) 0x68, (byte) 0x20, (byte) 0x74, (byte) 0x65, (byte) 0x78,            (byte) 0x74, (byte) 0x2e};
    上面我已经进行了一些说明,第一个字节:flags对应字节的前5位,后三位对应tnf。第二个字节:type length,这里是1。第三个字节:payload 长度,这里是28。第四个字节:type,这里是"T"。对于smartPoseter,type length就是2,对应的第四和第五个字节应该是'S'和'p'。
      然后就是payload

原创粉丝点击