写一个Intent到NFC标签?

时间:2011-09-22 17:40:18

标签: android nfc

是否可以将意图对象写入NFC标签?例如,如果我可以将以下意图写入NFC标签:

String phoneNumber = "5555555555";
Uri uri = Uri.parse("sms:" + phoneNumber);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
intent.putExtra("address", phoneNumber);
intent.setType("vnd.android-dir/mms-sms");

String intentAsUri = intent.toUri(0);
// = #Intent;action=android.intent.action.VIEW;type=vnd.android-dir/mms-sms;S.address=5555555555;end

然后我可以将输出uri作为url数据写入NFC标签。当用户点击我的标签时,android解释为上述意图,并启动短信使者?它似乎无法工作,我也不知道有一种方法可以将一个意图对象本身序列化到一个NFC标签上(或者知道那个解释一个的标签)

由于

2 个答案:

答案 0 :(得分:1)

您可以编写一个特殊的网址来调用短信应用:sms:+tel_no。添加正文文本存在一些问题:请参阅here

答案 1 :(得分:0)

有多种类型的NDEF'定义 - 大多数属于' U' URI操作,包括子类型0(无操作),它允许您用任何内容填充空间并在应用程序中相应地执行操作。然而,还有类型' T'用于文本操作(但必须与国际代码页一起使用)。

http://members.nfc-forum.org/specs/spec_list/作为起点,但您可能已经知道了这一点。