Wednesday, May 18, 2011

[android-developers] Re: NFC send Url p2p

Parsing is part of the NFCDemo app.
http://developer.android.com/resources/samples/NFCDemo

Sending a URL would probably be just doing it the other way around
using NDEF Push. Haven't tried it yet, but I believe something like
this should work:

In onCreate()...

mAdapter = NfcAdapter.getDefaultAdapter(this);

String url = "http://example.com";
byte[] payload = url.getBytes();
NdefRecord ndefRecord = new NdefRecord(NdefRecord.TNF_ABSOLUTE_URI,
NdefRecord.RTD_URI, new byte[0], payload);
mNdefPushMessage = new NdefMessage(new NdefRecord[]
{ ndefRecord });

...and in onResume():

mAdapter.enableForegroundNdefPush(this, mNdefPushMessage);

/Adam

On 18 Maj, 12:46, "arik...@hotmail.com" <arik...@hotmail.com> wrote:
> Hi I would like to know how I can send a url for a nexus S nfc to
> another, How can I parse the url from the mobile that receives it.
>  Thank you very much

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate