管理中心
我的

制作标签

本文导读

概述

标签需要写入一条AirTouch格式记录,和一条MIME格式记录,尽量按照顺序写入。

标签格式:

标签写入代码样例:

String airTouchContent = "下载的标签内容";
String airTouchDefaultLink = "默认跳转链接";
// 若选择"标签中关联MimeType的PayLoad作为查询参数",需要以下两个变量
String airTouchJumpParamKey = "跳转链接参数";
String airTouchJumpParamValue = "跳转链接参数值";
byte[] TYPE_HW = {0x68, 0x77};
NdefMessage ndefMessage = new NdefMessage(
    new NdefRecord[] {
        new NdefRecord(NdefRecord.TNF_MIME_MEDIA, TYPE_HW, new byte[0], Base64.decode(airTouchContent, Base64.NO_WRAP)),
        // 若选择"标签中关联MimeType的PayLoad作为查询参数",需要加入以下NdefRecord
        new NdefRecord(NdefRecord.TNF_MIME_MEDIA, airTouchJumpParamKey, new byte[0], airTouchJumpParamValue),
    }
);
.......
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
Ndef ndef = Ndef.get(tag);
......
ndef.writeNdefMessage(ndefMessage);
说明

当跳转链接参数来源配置为标签中关联MimeType的PayLoad作为查询参数时,MIME格式记录不可为空,否则可为空。

如果没有代码开发条件或期望快速接入,可以使用我们提供的标签烧录工具进行写入。