如何在android中创建Tag对象? [英] How do i create an Tag object in android?
本文介绍了如何在android中创建Tag对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试实例化Tag对象的方法.我正在尝试这样做,以便可以模拟各种类型的标签.
I've been trying to find a way to instantiate the Tag object. I'm trying to do this so that i can simulate various types of Tags.
有没有人知道如何使用UltraLight对象的实例
Does anyone know how to get an instance of UltraLight object using
Tag tag = ?????
UltraLight obj = UltraLight.get(tag);
谢谢
推荐答案
在NFC应用程序ICS源代码示例中,我们可以找到一些代码,例如:
In the NFC app example for ICS source code, we can find some code such as:
Bundle extras = new Bundle();
extras.putParcelable(Ndef.EXTRA_NDEF_MSG, ndefMsg);
extras.putInt(Ndef.EXTRA_NDEF_MAXLENGTH, 0);
extras.putInt(Ndef.EXTRA_NDEF_CARDSTATE, Ndef.NDEF_MODE_READ_ONLY);
extras.putInt(Ndef.EXTRA_NDEF_TYPE, Ndef.TYPE_OTHER);
Tag tag = Tag.createMockTag(new byte[] { 0x00 },
new int[] { TagTechnology.NDEF },
new Bundle[] { extras });
此createMockTag
方法的代码如下:
public static Tag createMockTag(byte[] id, int[] techList, Bundle[] techListExtras) {
// set serviceHandle to 0 to indicate mock tag
return new Tag(id, techList, techListExtras, 0, null);
}
也许这会有所帮助.
这篇关于如何在android中创建Tag对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文