Code example for NfcAdapter

Methods: setNdefPushMessage

    public void beamClicked(View v) {
        String message = et.getText().toString();
        Log.d("NFCKICKSTARTER", "Attempting to beam! Message is " + message);
        mNfcAdapter.setNdefPushMessage(createNdefMessage(message), this);
    public NdefMessage createNdefMessage(String message) {
        NdefRecord record = NdefRecord.createMime("application/", message.getBytes());
        return new NdefMessage(new NdefRecord[]{record});
    public void onResume() { 
        // Check to see that the Activity started due to an Android Beam 
        if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
            Parcelable[] rawMsgs = getIntent().getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);
            // only one message sent during the beam