Professional Documents
Culture Documents
Ashutosh Tripathi
Talentica Softwares
Agenda
What is NFC ? Why NFC ? How NFC works NFC & Mobiles Building NFC App Android Security Aspects
What is NFC ?
3
Near Field Communication Short Range Wireless (a few centimeters) Operates at frequency 13.56 MHz Less speed (106kbps 414 kbps) Low Friction Setup Passive Targets
Why NFC ?
5
Wireless Nirvana
Google Wallet
Stores virtual version of your existing cards Tap and pay Receive loyalty cards, recipiets Secure
Initiator
Active Device
Target
Active/Passive Device
Passive
Target device may draw its operating power from the initiatorprovided electromagnetic field
11
Operating modes
Reader/Writer Peer to Peer Card Emulation
Card emulation Smart Card capability for mobile devices Card Emulation Mode Peer 2 Peer Mode Application Reader/Writer Mode
LLCP
12
13
NDEF Record
Flags
MB,ME,CF,SR
14
Type Name Format Empty NFC Forum Well Known Type MIME Type Absolute URI NFC Forum External Type Unknown Unchanged Reserved
15
Already in Market..
Google Nexus S (1st NFC Android Phone) Samsung Galaxy SII (android) Nokia C7 Blackberry Bold 9900 and 9930 Nokia 6131 (1st NFC Phone now out of market)
17
18
Future Market
19
20
22
How we start
Essential
Set required permission in Manifest Add required intent filers in Manifest Handle intent in main Activity to read data
Working approach
Intent Dispatch : identify appropriate application Foreground Dispatch : intercept in your application
23
Set Minimum SDK version required . Supported above API level 9 only
<uses-sdk android:minSdkVersion="9" />
25
26
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); NdefMessage msg = getNdefMessage(getIntent()); // process msg }
if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) { msgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES)[0]; if (msg == null) { byte[] empty = new byte[] {}; NdefRecord record = new NdefRecord(NdefRecord.TNF_UNKNOWN, empty, empty, empty); msg = new NdefMessage(new NdefRecord[] {record}); } } else { // Your logic } return msg; }
28
Writing data:
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);
29
Security Aspects
30
31
32
Thanks
33