# 制作标签

#### 概述

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

标签格式：

* AirTouch格式记录（参见[AirTouch格式说明](https://developer.huawei.com/consumer/cn/doc/service/format-description-0000002112248816)）。
* MIMIE Record：AirTouch服务申请时配置的[跳转链接参数](https://developer.huawei.com/consumer/cn/doc/service/create-service-0000002105172798#ZH-CN_TOPIC_0000002105172798__li1186393215514)。

标签写入代码样例：

```
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);
```

![](https://media:201775733485465488)  
当[跳转链接参数来源](https://developer.huawei.com/consumer/cn/doc/service/create-service-0000002105172798#ZH-CN_TOPIC_0000002105172798__li1286220323515)配置为标签中关联MimeType的PayLoad作为查询参数时，MIME格式记录不可为空，否则可为空。

如果没有代码开发条件或期望快速接入，可以使用我们提供的[标签烧录工具](https://developer.huawei.com/consumer/cn/doc/service/make-tool-0000002563220571)进行写入。  
