打印
[近场通讯(NFC)]

【资料分享】Android NFC通信例子

[复制链接]
1028|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
地瓜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

相关帖子

沙发
keji1| | 2014-3-24 22:42 | 只看该作者
这个好

使用特权

评论回复
板凳
地瓜patch|  楼主 | 2014-3-25 21:58 | 只看该作者
你玩玩啊

使用特权

评论回复
地板
从小木丁丁| | 2014-4-5 15:17 | 只看该作者
这个好

使用特权

评论回复
5
老游| | 2014-4-5 21:23 | 只看该作者
还有程序啊

使用特权

评论回复
6
骗子的片子| | 2014-4-6 22:34 | 只看该作者
老游 发表于 2014-4-5 21:23
还有程序啊

老游同志你好

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

1170

主题

11288

帖子

27

粉丝