I need some help in handling data which was received by NFC. I'm using this code to receive an NDEF message over NFC and display the text contained in the NDEF record in a toast.
Now I want to fill the received data into an EditText
field. Right now it just shows the received data for a while (as a toast). I've tried to change the code, but I wasn't successful:
void parseNdefMessage(Intent intent) {
Parcelable[] ndefMessageArray = intent.getParcelableArrayExtra(
NfcAdapter.EXTRA_NDEF_MESSAGES);
NdefMessage ndefMessage = (NdefMessage) ndefMessageArray[0];
Toast.makeText(this, new String(ndefMessage.getRecords()[0].getPayload()), Toast.LENGTH_LONG).show();
Toast.makeText(
getApplicationContext(),"Here is my text",
Toast.LENGTH_LONG).show();
editText.getText().toString().equals(ndefMessage.getRecords()[0].getPayload()[0]);
//editText = (EditText) findViewById(R.id.editText);
//String text = editText.getText().toString();
editText.setText(ndefMessage.getRecords()[0].getPayload()[0]); //my attempt to set my received data to "editText" field
}
Could anyone give some advice about this?