android.nfc.tech.Ndef.get()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中android.nfc.tech.Ndef.get()方法的一些代码示例,展示了Ndef.get()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ndef.get()方法的具体详情如下:
包路径:android.nfc.tech.Ndef
类名称:Ndef
方法名:get

Ndef.get介绍

暂无

代码示例

代码示例来源:origin: commonsguy/cw-omnibus

Ndef ndef=Ndef.get(tag);

代码示例来源:origin: RickyYu/Nfc-Android

@Override
public void onNewIntent(Intent intent) {
  //获取Tag对象
  Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
  //获取Ndef的实例
  Ndef ndef = Ndef.get(detectedTag);
  mTagText = ndef.getType() + "\n max size:" + ndef.getMaxSize() + " bytes\n\n";
  readNfcTag(intent);
  mNfcText.setText(mTagText);
}

代码示例来源:origin: bparmentier/WiFiKeyShare

public static WifiConfiguration readTag(Tag tag) {
  Ndef ndef = Ndef.get(tag);
  if (ndef == null) {
    Log.d(TAG, "NDEF not supported");
    return null;
  }
  NdefMessage ndefMessage = ndef.getCachedNdefMessage();
  if (ndefMessage == null) {
    Log.d(TAG, "ndefMessage is null");
    return null;
  }
  return NfcUtils.parse(ndefMessage);
}

代码示例来源:origin: RickyYu/Nfc-Android

/**
   * 写数据
   *
   * @param ndefMessage 创建好的NDEF文本数据
   * @param tag         标签
   * @return
   */
  public static boolean writeTag(NdefMessage ndefMessage, Tag tag) {
    try {
      Ndef ndef = Ndef.get(tag);
      ndef.connect();
      ndef.writeNdefMessage(ndefMessage);
      return true;
    } catch (Exception e) {
    }
    return false;
  }
}

代码示例来源:origin: commonsguy/cw-omnibus

Ndef ndef=Ndef.get(tag);

代码示例来源:origin: RickyYu/Nfc-Android

@Override
public void onNewIntent(Intent intent) {
  //1.获取Tag对象
  Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
  //2.获取Ndef的实例
  Ndef ndef = Ndef.get(detectedTag);
  mTagText = ndef.getType() + "\nmaxsize:" + ndef.getMaxSize() + "bytes\n\n";
  readNfcTag(intent);
  mNfcText.setText(mTagText);
}

代码示例来源:origin: skjolber/external-nfc-api

Ndef ndef = Ndef.get(tag);
if(ndef == null) {
  throw new IllegalArgumentException("No NDEF");

代码示例来源:origin: tyrex-team/senslogs

public void handleTag(Tag tag) {
  Ndef ndef = Ndef.get(tag);
  // NDEF is not supported by this Tag.
  if (ndef == null) return;
  NdefMessage ndefMessage = ndef.getCachedNdefMessage();
  NdefRecord[] records = ndefMessage.getRecords();
  for (NdefRecord ndefRecord : records) {
    if (ndefRecord.getTnf() == NdefRecord.TNF_WELL_KNOWN) {
      try {
        broadcastText(readText(ndefRecord));
      } catch (UnsupportedEncodingException ignored) {
      }
    }
  }
}

代码示例来源:origin: RickyYu/Nfc-Android

/**
   * 写入标签
   *
   * @param message
   * @param tag
   * @return
   */
  public static boolean writeTag(NdefMessage message, Tag tag) {
    int size = message.toByteArray().length;
    try {
      Ndef ndef = Ndef.get(tag);
      if (ndef != null) {
        ndef.connect();
        if (!ndef.isWritable()) {
          return false;
        }
        if (ndef.getMaxSize() < size) {
          return false;
        }
        ndef.writeNdefMessage(message);
        return true;
      }
    } catch (Exception e) {
    }
    return false;
  }
}

代码示例来源:origin: skjolber/external-nfc-api

this.ndef = Ndef.get(tag);

代码示例来源:origin: Mobisocial/EasyNFC

private int writeTag(Tag tag, NdefMessage message) {
  try {
    int size = message.toByteArray().length;
    Ndef ndef = Ndef.get(tag);
    if (ndef != null) {
      ndef.connect();

代码示例来源:origin: RickyYu/Nfc-Android

try {
  Ndef ndef = Ndef.get(tag);

代码示例来源:origin: RickyYu/Nfc-Android

try {
  Ndef ndef = Ndef.get(tag);

代码示例来源:origin: skjolber/ndef-tools-for-android

Ndef ndef = Ndef.get(tag);
if(ndef != null) {
  try {

代码示例来源:origin: bparmentier/WiFiKeyShare

Ndef ndef = Ndef.get(tag);
if (ndef != null) {
  ndef.connect();

代码示例来源:origin: skjolber/ndef-tools-for-android

Ndef ndef = Ndef.get(tag);
if(ndef != null) {
  try {

相关文章