I develop an Android app to read/write on contactless smart cards through NFC. I need to detect when the card is pulled out of range. I tried to use
NFCAdapter.OnTagRemovedListener{
card_connected2.visibility = View.VISIBLE
card_connectedgreen.visibility = View.GONE
Toast.makeText(this@InquiryActivity, "card is disconnected", Toast.LENGTH_LONG).show()
}
but this seems wrong and does not work. I also read about NfcAdapter.ignore()
, but I can't find any example about how to use it. How can I get the above callback to work?