How to find out whether an NFC tag is still in range of an Android now?

前端 未结 2 1660
情深已故
情深已故 2020-12-03 06:22

As I know when an Android phone gets an NFC tag touched, it will send an event (NDEF_DISCOVERED intent), but Android doesn\'t seem to care whether this tag is staying in pla

2条回答
  •  甜味超标
    2020-12-03 07:05

    There is a function that checks to see if the card is still connected called isConnected(). Can be used like this:

    try {
        ndef.connect();
        while(ndef.isConnected()){
    
        //Your code here
    
        }
    } catch (IOException e) {
        //Error
    }
    

提交回复
热议问题