Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NFC service dead - attempting to recover

Tags:

android

nfc

I have an application which reads & writes the data into the NFC tag(Type 2). Some times while reading the tag i am getting the below error in LogCat.

03-13 12:26:12.946: E/NFC(18889): NFC service dead - attempting to recover
03-13 12:26:12.946: E/NFC(18889): android.os.DeadObjectException
03-13 12:26:12.946: E/NFC(18889):   at android.os.BinderProxy.transact(Native Method)
03-13 12:26:12.946: E/NFC(18889):   at android.nfc.INfcAdapter$Stub$Proxy.setForegroundDispatch(INfcAdapter.java:350)
03-13 12:26:12.946: E/NFC(18889):   at android.nfc.NfcAdapter.disableForegroundDispatchInternal(NfcAdapter.java:1062)
03-13 12:26:12.946: E/NFC(18889):   at android.nfc.NfcAdapter.disableForegroundDispatch(NfcAdapter.java:1050)

Does any have any idea why is this happening. Is there any way to fix this.

Thanks.

like image 453
ravi Avatar asked Nov 02 '22 03:11

ravi


1 Answers

I have come across the same issue and was able to resolve. This happens when you try to invoke NFC beam, when Activity is not in Resumed State.

NFCBeamShareData checks if the current activity is in resume state. If the current activity is not in resume state, it will return null object and causes NullPointerException or DeadObjectException.

like image 142
BlackPearl Avatar answered Nov 12 '22 16:11

BlackPearl