• <i id='bNl6P'><tr id='bNl6P'><dt id='bNl6P'><q id='bNl6P'><span id='bNl6P'><b id='bNl6P'><form id='bNl6P'><ins id='bNl6P'></ins><ul id='bNl6P'></ul><sub id='bNl6P'></sub></form><legend id='bNl6P'></legend><bdo id='bNl6P'><pre id='bNl6P'><center id='bNl6P'></center></pre></bdo></b><th id='bNl6P'></th></span></q></dt></tr></i><div id='bNl6P'><tfoot id='bNl6P'></tfoot><dl id='bNl6P'><fieldset id='bNl6P'></fieldset></dl></div>

      1. <small id='bNl6P'></small><noframes id='bNl6P'>

          <bdo id='bNl6P'></bdo><ul id='bNl6P'></ul>
      2. <legend id='bNl6P'><style id='bNl6P'><dir id='bNl6P'><q id='bNl6P'></q></dir></style></legend>

        <tfoot id='bNl6P'></tfoot>
      3. 无法使用 NdefFormatable 格式化 NFC 卡

        时间:2023-08-31

          <tfoot id='ikLmE'></tfoot>
        1. <small id='ikLmE'></small><noframes id='ikLmE'>

                <bdo id='ikLmE'></bdo><ul id='ikLmE'></ul>
                  <tbody id='ikLmE'></tbody>

                  <legend id='ikLmE'><style id='ikLmE'><dir id='ikLmE'><q id='ikLmE'></q></dir></style></legend>
                  <i id='ikLmE'><tr id='ikLmE'><dt id='ikLmE'><q id='ikLmE'><span id='ikLmE'><b id='ikLmE'><form id='ikLmE'><ins id='ikLmE'></ins><ul id='ikLmE'></ul><sub id='ikLmE'></sub></form><legend id='ikLmE'></legend><bdo id='ikLmE'><pre id='ikLmE'><center id='ikLmE'></center></pre></bdo></b><th id='ikLmE'></th></span></q></dt></tr></i><div id='ikLmE'><tfoot id='ikLmE'></tfoot><dl id='ikLmE'><fieldset id='ikLmE'></fieldset></dl></div>
                  本文介绍了无法使用 NdefFormatable 格式化 NFC 卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  I am using NdefFormatable class to format my NFC card. The code is like:

                  NdefFormatable formatable=NdefFormatable.get(tag);
                  

                  But i get formatable reference as null. I checked the code that is run inside the get(tag) method. It checks:

                  if (!tag.hasTech(TagTechnology.NDEF_FORMATABLE)) return null;
                  

                  I ran "tag.getTechList()" for my tag. I got:

                  android.nfc.tech.NfcA
                  android.nfc.tech.Ndef
                  

                  I was able to format this card using Trigger application.

                  What can be done to format this.

                  解决方案

                  The NdefFormatable and the Ndef tag technologies are mutually exclusive. Either your tag is not yet NDEF formatted (i.e. it is not yet prepared to store NDEF messages) or it is already prepared to store NDEF messages (and already contains (at least an empty) an NDEF message).

                  So NdefFormatable is only used for writing an initial NDEF message to a tag.

                  As your tag already lists the android.nfc.tech.Ndef technology, it is already prepared to store an NDEF message and does not need further formatting. You can simply overwrite (given that the tag is not read-only) any existing NDEF message by using the writeNdefMessage() method of the Ndef object. E.g. to "format" the tag to an empty NDEF message, you could do something like:

                  Ndef ndefTag = Ndef.get(tag);
                  ndefTag.writeNdefMessage(new NdefMessage(new NdefRecord(NdefRecord.TNF_EMPTY, null, null, null)));
                  


                  Update: On devices with the libnfc-nci NFC stack, it seems that NdefFormatable and Ndef tag technologies are no longer mutually exclusive. Formatted tags will (sometimes?) be enumerated as both NdefFormatable and Ndef. In thoses cases, you would still typically try to use the Ndef first and only if that fails use the NdefFormatable object.

                  这篇关于无法使用 NdefFormatable 格式化 NFC 卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Swift 2.0 将 1000 格式化为友好的 K 下一篇:Objective-C:将数字格式化为序数:1, 2, 3, .. to 1st, 2

                  相关文章

                  最新文章

                  <small id='HsAD1'></small><noframes id='HsAD1'>

                    <bdo id='HsAD1'></bdo><ul id='HsAD1'></ul>
                • <legend id='HsAD1'><style id='HsAD1'><dir id='HsAD1'><q id='HsAD1'></q></dir></style></legend>
                • <tfoot id='HsAD1'></tfoot>

                      <i id='HsAD1'><tr id='HsAD1'><dt id='HsAD1'><q id='HsAD1'><span id='HsAD1'><b id='HsAD1'><form id='HsAD1'><ins id='HsAD1'></ins><ul id='HsAD1'></ul><sub id='HsAD1'></sub></form><legend id='HsAD1'></legend><bdo id='HsAD1'><pre id='HsAD1'><center id='HsAD1'></center></pre></bdo></b><th id='HsAD1'></th></span></q></dt></tr></i><div id='HsAD1'><tfoot id='HsAD1'></tfoot><dl id='HsAD1'><fieldset id='HsAD1'></fieldset></dl></div>