Prevent NFC Service app from opening when reading empty tag with enableReaderMode

98 Views Asked by At

Moving from the enableForgroundDispatch (I don't seem to get it working on api 32) intent based way of reading NFC-tags to enableReaderMode. The latter one works well, but every now and then the NFC Service app is opening, showing 'emtpy tag' message. Is there a way to disable this, in code? It's true that the tags are empty, only reading and using the tag Id. Code look like the following;

  Bundle opts = new Bundle();
  opts.putInt(NfcAdapter.EXTRA_READER_PRESENCE_CHECK_DELAY, 250);
  getNfcAdapter().enableReaderMode(this, tag -> {
            // passing tag to get tag.getId()   
            myViewModel.setTag(tag);

  }, NfcAdapter.FLAG_READER_NFC_A |
     NfcAdapter.FLAG_READER_NFC_B |
     NfcAdapter.FLAG_READER_NFC_F |
     NfcAdapter.FLAG_READER_NFC_V |
     NfcAdapter.FLAG_READER_NFC_BARCODE |
     NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK |
     NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS
  , opts);
0

There are 0 best solutions below