[近场通讯(NFC)] 【资料分享】Android NFC通信例子

[复制链接]
 楼主| 地瓜patch 发表于 2014-3-22 12:20 | 显示全部楼层 |阅读模式
/* NFCard is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

NFCard is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

Additional permission under GNU GPL version 3 section 7 */

package com.sinpo.xnfc;

public final class Util {
        private final static char[] HEX = { '0', '1', '2', '3', '4', '5', '6', '7',
                        '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };

        private Util() {
        }

        public static byte[] toBytes(int a) {
                return new byte[] { (byte) (0x000000ff & (a >>> 24)),
                                (byte) (0x000000ff & (a >>> 16)),
                                (byte) (0x000000ff & (a >>> 8)), (byte) (0x000000ff & (a)) };
        }

        public static int toInt(byte[] b, int s, int n) {
                int ret = 0;

                final int e = s + n;
                for (int i = s; i < e; ++i) {
                        ret <<= 8;
                        ret |= b[i] & 0xFF;
                }
                return ret;
        }

        public static String toHexStringR(byte[] d, int s, int n) {
                final char[] ret = new char[n * 2];

                int x = 0;
                for (int i = s + n - 1; i >= s; --i) {
                        final byte v = d[i];
                        ret[x++] = HEX[0x0F & (v >> 4)];
                        ret[x++] = HEX[0x0F & v];
                }
                return new String(ret);
        }

}

NFC例程.rar

410.68 KB, 下载次数: 12

keji1 发表于 2014-3-24 22:42 | 显示全部楼层
这个好
 楼主| 地瓜patch 发表于 2014-3-25 21:58 | 显示全部楼层
你玩玩啊
从小木丁丁 发表于 2014-4-5 15:17 来自手机 | 显示全部楼层
这个好
老游 发表于 2014-4-5 21:23 | 显示全部楼层
还有程序啊
骗子的片子 发表于 2014-4-6 22:34 | 显示全部楼层
老游 发表于 2014-4-5 21:23
还有程序啊

老游同志你好
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:出一块TI-PLABS-AMP-EVM

1803

主题

14836

帖子

29

粉丝
快速回复 在线客服 返回列表 返回顶部