我被要求在智能海报标签中写入以下数据。
1)折扣优惠URL 2)计数值(如前200条优惠)
如何以编程方式在smart poster中写入这些信息?
它是可以写成键/值对的东西吗?
任何指向示例代码的指针都可以对我有很大帮助?
提前谢谢。
发布于 2012-11-08 12:30:57
我认为需求1)和2)是两个不同的层次。请求1)是在Android/NFC编程级别上,使用TNF_WELL_KNOWN和RTD-SMART_POSTER(因为这是一个网址,usingRTD_URI就是正确的)。
下面是一些代码:
private NdefRecord createRecord(String text)
throws UnsupportedEncodingException {
//Intent intent = getIntent();
//EditText editTextWeb = (EditText)
EditText editText = (EditText) findViewById(R.id.editTextWeblinks);
String webLink = editText.getText().toString();
byte[] uriField = webLink.getBytes(Charset.forName("US-ASCII"));
byte[] payload = new byte[uriField.length + 1]; //1 =URIPrefix
payload[0] = 0x01; //http://www. to the URI
System.arraycopy(uriField, 0, payload, 1, uriField.length); //appends URI to payload
NdefRecord rtdUriRecord = new NdefRecord(
NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_URI, new byte[0], payload);
return rtdUriRecord;
}根据请求。2我们有一个棘手的部分。使用Android/NFC API,您可以识别您编写的每个标签,但您不能在NF标签中添加某种计数器程序逻辑,此功能必须在外部应用程序上执行(在Android、PC、Mac、自定义设备等上命名)。
奇妙的方式:为您的业务的销售和优惠构建定制的NFC终端。简单的做法是:在收银员的电脑上创建一个简单的应用程序来扫描条形码(下载的图像),并使用该事件编写计数器。
希望能有所帮助。
https://stackoverflow.com/questions/9290245
复制相似问题