Code example for NfcAdapter

Methods: setNdefPushMessage

0
    } 
 
    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/vnd.com.mobdevcon.nfckickstarter.beam", message.getBytes());
        return new NdefMessage(new NdefRecord[]{record});
    } 
 
    @Override 
    public void onResume() { 
        super.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 
            NdefMessage msg = (NdefMessage) rawMsgs[0];