1 / 11

NFC

NFC. 2. What is NFC?. N ear F iled C ommunication Is a short range high frequency wireless communication technology Low speed (106 to 424 kbps) Low friction setup (no discovery, no pairing) NFC is an extension of Radio frequency identification (RFID) technology

winona
Download Presentation

NFC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. NFC

  2. 2 What is NFC? • Near Filed Communication • Is a short range high frequency wireless communication technology • Low speed (106 to 424 kbps) • Low friction setup (no discovery, no pairing) • NFC is an extension of Radio frequency identification (RFID) technology - RFID is mainly used for tracking and identification by sending radio waves

  3. How NFC works? Use NFC to read information from a tag Use NFC to read peer to peer information

  4. How NFC is used with Android? • NFC feature is available from Android 2.3 version • Android Ice Cream Sandwich 4.0 introduced a new peer-to-peer interaction model • 0-click contact sharing • 0-click web page sharing • 0-click youtube video sharing

  5. How to NFC? Reading NDEF data from an NFC tag = Nfc Data Exchange Format • By design, NDEF data is dispatched to only one activity • The type of the first NDEF record is used for dispatch • The data container format for NFC More on http://developer.android.com/reference/android/nfc/NdefMessage.html http://developer.android.com/reference/android/nfc/NdefRecord.html

  6. Reading NDEF data Different Dispatch Types

  7. Reading NDEF data How to use NFC reading within Java code • Android Manifest <intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED"/> <categoryandroid:name="android.intent.category.DEFAULT"/> <dataandroid:mimeType="text/plain"/> </intent-filter> • Activity class onResume @Override protectedvoid onResume() { … if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) { NdefMessage[] messages = getNdefMessages(getIntent()); byte[] payload = messages[0].getRecords()[0].getPayload(); … }

  8. Writing NDEF data Writing NDEF tags String text; NdefRecord textRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA,"text/plain".getBytes(), text.getBytes()); NdefMessage textMessage = new NdefMessage(new NdefRecord[]{textRecord}); Tag tag = getIntent().getExtra(NfcAdapter.EXTRA_TAG); Ndef ndef = Ndef.get(tag); ndef.writeNdefMessage(textMessage);

  9. Writing NDEF data Writing Peer to Peer • Foreground Activities can register an NDEF payload for P2P push Register the payload in advance adapter.enableForegroundNdefPush(this, ndefMessage); • Ice Cream Sandwich preview Register interest in P2P in advance, push the payload live public interface NdefPushCallback { public NdefMessage createMessage(); } adapter.registerForegroundNdefPush(this, callback);

  10. Sources http://developer.android.com/guide/topics/connectivity/nfc/nfc.html#tag-dispatch http://static.googleusercontent.com/external_content/untrusted_dlcp/www.google.com/en//events/io/2011/static/presofiles/how_to_nfc.pdf http://www.jessechen.net/blog/how-to-nfc-on-the-android-platform/ http://developer.android.com/reference/android/nfc/package-summary.html

  11. Questions & (hopefully) Answers String question = audience.getNextQuestion(); while (question != null && timeLeft.getValue() > 0) { try { answer(question); } catch (AnswerNotKnownException e) { MakeSomethingUp(); LOG.warn("Missed one: " + question, e); } question = audience.getNextQuestion(); timeLeft.update(); } audience.thankForAttention();

More Related