Your checking that the mNfcAdapter
is not null
, yet still try to access it afterward even if it is. Try moving these lines
mNfcAdapter.setNdefPushMessageCallback(this, this, new Activity[0]);
mNfcAdapter.setOnNdefPushCompleteCallback(this, this, new Activity[0]);
into an else
to the previous if
:
if (mNfcAdapter == null) {
myText.setText("NFC is not available on this device.");
myText.setEnabled(false);
} else {
mNfcAdapter.setNdefPushMessageCallback(this, this, new Activity[0]);
mNfcAdapter.setOnNdefPushCompleteCallback(this, this, new Activity[0]);
}