0

i'm using 2 Galaxy S3 and i send a message from one to the other. I want the other to send back a response like "received msg" i'm using the android beam demo, and i want to add this ack.I send the ack message when i treat the first message in ProcessIntent with a simple "sendNdefMessage"? how do i manage the receipt of the ack in the other device?

void processIntent(Intent intent) {
    Parcelable[] rawMsgs = intent.getParcelableArrayExtra(
            NfcAdapter.EXTRA_NDEF_MESSAGES);
    // only one message sent during the beam
    NdefMessage msg = (NdefMessage) rawMsgs[0];
    // record 0 contains the MIME type, record 1 is the AAR, if present
    mInfoText.setText(new String(msg.getRecords()[0].getPayload()));

    //ack message
    mNfcAdapter.setNdefPushMessageCallback(ackMsg, this);
}

Thanks a lot

Michael Roland
  • 39,663
  • 10
  • 99
  • 206
user1482868
  • 31
  • 2
  • 5

1 Answers1

1

You cannot send a message back, unfortunately. However, the device that sent the message knows when it has been received successfully. Your app can be notified of this by registering a callback with NfcAdapter.OnNdefPushCompleteCallback()

NFC guy
  • 10,151
  • 3
  • 27
  • 58
  • it means you cannot establish a communication between 2 devices. You only can send 1 message at a time. How can you do otherwise? – user1482868 Oct 05 '12 at 08:40
  • 1
    This is all the NFC peer-to-peer functionality that has currently been implemented Android... :( – NFC guy Oct 05 '12 at 08:54