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

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

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

Ndef.getMaxSize介绍

暂无

代码示例

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

text="Tag is read-only";
else if (ndef.getMaxSize()<size) {
 text="Message is too big for tag";

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

text=host.getString(R.string.tag_is_read_only);
else if (ndef.getMaxSize() < size) {
 text=host.getString(R.string.message_is_too_big_for_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: 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: Mobisocial/EasyNFC

return OnTagWriteListener.WRITE_ERROR_READ_ONLY;
if (ndef.getMaxSize() < size) {
  Log.d(TAG, "Tag capacity is " + ndef.getMaxSize() + " bytes, message is " +
      size + " bytes.");
  return OnTagWriteListener.WRITE_ERROR_CAPACITY;

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

if (ndef.getMaxSize() < size) {
  return;

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

int maxSize = ndef.getMaxSize();

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

if (ndef.getMaxSize() < size) {
  return;

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

if (ndef.getMaxSize() < rawMessage.toByteArray().length) {
  Log.d(TAG, "Tag size is too small, have " + ndef.getMaxSize() + ", need " + rawMessage.toByteArray().length);
  writeNdefTooSmall(rawMessage.toByteArray().length, ndef.getMaxSize());

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

return false;
int ndefMaxSize = ndef.getMaxSize();
if (messageSize > ndefMaxSize) {

代码示例来源: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;
  }
}

相关文章