简体   繁体   English

Android NDEF NFC有效负载

[英]Android NDEF NFC Payload

I am using NDEF nfc cards and my application is reading the data in the card. 我正在使用NDEF nfc卡,而我的应用程序正在读取卡中的数据。 Everything works great. 一切正常。 However as part of the payload I am also getting the language type in it. 但是,作为有效负载的一部分,我也要在其中获取语言类型。

If the NFC string is "Hello"

String text = new String(records.get(k).getNdefRecord().getPayload());

Output is "enHello"

I am sure I can use substring to remove the first two characters but is there a way to get Payload message only without getting the language string in it? 我确定我可以使用子字符串删除前两个字符,但是有没有办法仅在不获取语言字符串的情况下获取有效载荷消息?

Any help will be very appreciated. 任何帮助将不胜感激。 Thank you in advance!! 先感谢您!!

What's your strategy for converting from a byte array to a String? 从字节数组转换为字符串的策略是什么? There's more data returned in getPayload() than simply the text you want to read. getPayload()返回的数据不仅仅是您要阅读的文本。 This link has a breakdown of the protocol, plus there's another link or two on SO like this one that explains how to handle it. 此链接有协议的崩溃,再加上有对SO另一个链接或两个这样的一个解释如何处理它。

I've implemented a library called NDEF Tools for Android for reading and writing high-level record representation from the basic NdefMessage/NdefRecord in Android. 我已经为Android实现了一个名为NDEF Tools的库, 用于从Android中的基本NdefMessage / NdefRecord读写高级记录表示。 See the Text Record for some pointers. 有关一些指针,请参见文本记录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM