没有接触过NFC的知识,一下子看这个Demo肯定挺吃力的,最近我就到了NFC forum里面下载了NFC Text tag, URI tag, Smart Poster, NDEF这四份文档,一一区把其读懂。我把我读懂的结果和大家分享一下,对于NFC的message,以后有空我会把这四份英文的文档翻译成中文。^_^
/*
* Copyright (C) 2010 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.android.nfc.simulator;
/**
* This class provides a list of fake NFC Ndef format Tags.
*/
public class MockNdefMessages {
/**
* A Smart Poster containing a URL and no text.
*/
public static final byte[] SMART_POSTER_URL_NO_TEXT = new byte[] {
//Message Header=11010 001(MB ME CF SR IL INF(001))
(byte) 0xd1, //MB=1 ME=1 CF=0 SR=1 IL=0 INF=001
(byte) 0x02,//Type length=2
(byte) 0x0f, // Payload length=15
//Type=SP-->This tag type is Smart Poster
(byte) 0x53,//S
(byte) 0x70,//P
//Payload
(byte) 0xd1, //11010 001(MB ME CF SR IL INF(001))
(byte) 0x01, //Type length=1
(byte) 0x0b, //Payload length=11
(byte) 0x55, // type=U-->record type is URI
//subPayload
(byte) 0x01,//URI Identifier code=1-->http:www.
//google.com
(byte) 0x67,(byte) 0x6f,(byte) 0x6f, (byte) 0x67, (byte) 0x6c, (byte) 0x65, (byte) 0x2e,
(byte) 0x63,(byte) 0x6f, (byte) 0x6d };
/**
* A plain text tag in english.
*/
public static final byte[] ENGLISH_PLAIN_TEXT = new byte[] {
(byte) 0xd1, //11010 001(MB ME CF SR IL INF(001))
(byte) 0x01,//Type length=11
(byte) 0x1c,//Payload length=28
(byte) 0x54,// Type=T-->record type is TEXT
(byte) 0x02,//Status byte 00000010 -->UTF-8, Language codes length=2
//Language Codes="en"
(byte) 0x65, // e
(byte) 0x6e, // n
// Some random english text
(byte) 0x53, (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 };
/**
* Smart Poster containing a URL and Text.
*/
public static final byte[] SMART_POSTER_URL_AND_TEXT = new byte[] {
(byte) 0xd1, //11010 001(MB ME CF SR IL INF(001))
(byte) 0x02,//Type length=2
(byte) 0x1c,//Payload length=28
//Type=SP
(byte) 0x53, //S
(byte) 0x70, //p
//------Text record----------------------------------------//
(byte) 0x91, //10010001(MB ME CF SR IL INF(001))
(byte) 0x01, //Type length=1
(byte) 0x09,//Payload length=9
(byte) 0x54, //Type=T-->TEXT
(byte) 0x02,//Status byte 00000010 -->UTF-8, Language codes length=2
//Language Codes="en"
(byte) 0x65, //n
(byte) 0x6e, //e
// Google
(byte) 0x47, (byte) 0x6f, (byte) 0x6f, (byte) 0x67, (byte) 0x6c,(byte) 0x65,
//------Text record----------------------------------------//
//---URI record------------------------------------------//
(byte) 0x51, //01010001(MB ME CF SR IL INF(001))
(byte) 0x01, //Type length=1
(byte) 0x0b,//Payload length=11
(byte) 0x55, // U
(byte) 0x01, // http://www.
// google.com
(byte) 0x67, (byte) 0x6f, (byte) 0x6f, (byte) 0x67, (byte) 0x6c,
(byte) 0x65, (byte) 0x2e, (byte) 0x63, (byte) 0x6f, (byte) 0x6d };
/**
* All the mock Ndef tags.
*/
public static final byte[][] ALL_MOCK_MESSAGES = new byte[][] {
SMART_POSTER_URL_NO_TEXT, ENGLISH_PLAIN_TEXT,
SMART_POSTER_URL_AND_TEXT };
}
分享到:
相关推荐
android NFC demo自动打开网页
android nfc 开发demo
android 使用nfc的demo
NFC读卡demo支持M1,NFC等芯片卡NFC读卡demo支持M1,NFC等芯片卡NFC读卡demo支持M1,NFC等芯片卡NFC读卡demo支持M1,NFC等芯片卡NFC读卡demo支持M1,NFC等芯片卡
Android NFC Demo1
NFC Demo myeclipse 工程源文件
android nfc开发demo。本人在里面写了不少注释,还有经过几天开发,这个demo已经应用公司app。根据这个demo可以写很多版本的简化版。我的csdn博客地址:http://blog.csdn.net/qq_16064871。我在博客中还有nfc开发...
自己写的android NFC 读标签DEMO 关键的地方都有标注,因为是读卡里所有扇区的数据,所以读卡时卡要放手机上多放一会会,直到数据都读出来
Android-NFC P2P学习源码,非常实用的~
基于android的nfc读写的demo,实现了NDEF格式和ultralight两种格式的读nfc标签的功能。
android NFC 公交卡信息读取demo,可以正常编译和测试
1.支持android设备读取nfc贴纸数据 2.支持向nfc卡中写入相关的数据 3.操作非常简单,只需要在在Activity中的onResume、onPause、onDestroy、onNewIntent方法中调用nfc工具类的相关方法就ok了,完整的步骤请查看demo
nfc.demo.
Near-field communication, NFC, is a technology used to provide short-range wireless connectivity to carry two-way interactions between electronic devices. NFC is promoted and maintained by the NFC ...
基于MSP430的NFC读写测试程序,可供参考。来源TI官网
实现扫一扫和NFC功能
NFC近场通讯芯片卡发资料,包含原理图、PCB图、程序代码DEMO文件
支持NFC功能的Android手机读取nfc卡信息,该demo可以读取卡片类型、扇区个数、每个扇区块中的数据,已经在手机上通过测试。
NFC读卡APP # 设计文档 ### 简介 ----------------------------- 这个APP的功能是使用手机的NFC读卡器功能,做到读取卡片 支持M1卡和CPU卡。 ### 功能列表 ----------------------------- - 基本功能 - 读卡唯...
安卓开发,NFC读取NFC标签ID(二)的demo。使用阅读器模式 API实现获取NFC标签ID的功能。同时实现控制NFC触发时声音以及震动。