本文整理汇总了Java中android.nfc.tech.TagTechnology类的典型用法代码示例。如果您正苦于以下问题:Java TagTechnology类的具体用法?Java TagTechnology怎么用?Java TagTechnology使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TagTechnology类属于android.nfc.tech包,在下文中一共展示了TagTechnology类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mockTag
import android.nfc.tech.TagTechnology; //导入依赖的package包/类
public Tag mockTag(String technology) throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException {
// For future reference
// Parameters :
byte[] b = {0x8};
String ndefClass = "android.nfc.tech.Ndef";
// FieldName which marks the capacity of the tag
String extraNdefMaxlength = (String) Class.forName(ndefClass).getField("EXTRA_NDEF_MAXLENGTH").get(null);
// FieldName which marks the tags writability
String cardWritableStateField = (String) Class.forName(ndefClass).getField("EXTRA_NDEF_CARDSTATE").get(null);
// Field to mark tag R/W
int cardWritable = Class.forName(ndefClass).getField("NDEF_MODE_READ_WRITE").getInt(null);
Bundle techExtras = new Bundle();
techExtras.putInt(extraNdefMaxlength, 2048);
techExtras.putInt(cardWritableStateField, cardWritable);
Bundle[] extras = {techExtras};
int[] technologies = {TagTechnology.class.getField(technology.toUpperCase()).getInt(null)}; //https://android.googlesource.com/platform/frameworks/base.git/+/android-4.3_r2/core/java/android/nfc/tech/TagTechnology.java
// https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/nfc/Tag.java :376
Parcel parcel = Parcel.obtain();
parcel.writeByteArray(b); //Sets the ID
parcel.writeIntArray(technologies); // Sets the technology to NDEF
parcel.writeArray(extras); // Needed to set properties for NDEF tag
parcel.writeInt(1); // Service handle
parcel.writeInt(1); // Indicating a mock
return Tag.CREATOR.createFromParcel(parcel);
}
示例2: NfcTagHandler
import android.nfc.tech.TagTechnology; //导入依赖的package包/类
protected NfcTagHandler(TagTechnology tech, TagTechnologyHandler handler) {
mTech = tech;
mTechHandler = handler;
}
示例3: hasTech
import android.nfc.tech.TagTechnology; //导入依赖的package包/类
/**
* Tegテクノロジを持っているか否かを検査します
* @param tag NFCタグをセット
* @param tech TagTechnologyクラスをセット
* @return boolean 対象のテクノロジクラス含んでいる場合はtrueが戻ります
*/
static public boolean hasTech(Tag tag, Class< ? extends TagTechnology> tech) {
return hasTech(tag, tech.getCanonicalName());
}