6. NFC roots: RFID
ā¢ RFID - Radio Frequency Identiļ¬cation
ā¢ 1983: First RFID patent granted
ā¢ Typical, well-known use-cases for RFID
animal identiļ¬cation, road taxes, libraries
ā¢ 2004: Nokia, Philips and Sony established
the NFC Forum
7. NFC
ā¢ ātransfer data at low speed, without
security, over short distancesā
ā¢ ~10 centimeters, in reality less
ā¢ 424 kBit/s
ā¢ 13.56 MHz
8. NFC Devices
ā¢ First mainstream Android
smartphone: Nexus S
ā¢ Common in new top
Android phones
ā¢ New RIM / Nokia devices
ā¢ Apple iPhone?
9. Nokia 6131
ā¢ released 2006
ā¢ early 2007: iPhone!
ā¢ J2ME Spec: JSR 257
Contactless Communication API
ā¢ NFC is not new!
36. NFCAdapter
ā¢ the real thing
ā¢ Control Foreground Dispatch and
P2P NDEF Push
ā¢ check if NFC is turned on
37. Checking for NFC
if (!getNFCAdapter().isEnabled())
{
Toast.makeText(getApplicationContext(),
"Please activate NFC and press back to return to the application!",
Toast.LENGTH_LONG).show();
startActivity(
new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS)
);
}
38. Reading a Tag
ā¢ Unlock phone,
touch tag :-)
ā¢ Most likely, the
intent chooser will
open
39. Foreground Dispatch
ā¢ Foreground Activity may redirect all intents
related to tag, technology or NDEF
discovery to itself
ā¢ Getting all tags while activity is visible:
enable in onResume(), disable in onPause()
40. Foreground Dispatch
nfcAdapter.enableForegroundDispatch( techListsArray does not matter
activity, here, as ACTION_TECH_DISCOVERED
is not in intentFilters array. It can
pendingIntent, be null :-)
intentFiltersArray,
Most basic TAG-catch-all:
techListsArray); use ACTION_TAG_DISCOVERED in
ļ¬lterList, no techs
intent = PendingIntent.getActivity(activity, 0,
new Intent(activity, activity.getClass())
.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0);
IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED);
ndef.addDataType("*/*");
intentFiltersArray = new IntentFilter[] { ndef };
techListsArray = new String[][] { new String[] { NfcA.class.getName() } };
41. Receiving a Tag
public void onNewIntent(Intent intent) {
Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
}
...
tag.getId() //returns id as byte[]
String techs[] = tag.getTechList();
for (String tech : techs) {
if (tech.equals("android.nfc.tech.Ndef"))
{
Ndef ndef = Ndef.get(tag);
ndef.getType()
ndef.getMaxSize()
ndef.canMakeReadOnly()
ndef.isWritable()
NFCUtil.printNdefMessageDetails(ndef.getCachedNdefMessage()));
}
}
42. Tag Technologies
Tag Technologies map to
tech speciļ¬cations or to
pseudo-technologie or
capabilities like NDEF or
NDEFFormatable
TagTechnology
MifareClassic MifareUltralight NdefFormatable Ndef
NfcA NfcB NfcF NfcV
IsoDep
43. Tag Technologies
Tag Technologies map to
tech speciļ¬cations or to
pseudo-technologie or
capabilities like NDEF or
NDEFFormatable
TagTechnology
MifareClassic MifareUltralight NdefFormatable Ndef
NfcA NfcB NfcF NfcV
IsoDep
44. NDEF
ā¢ NFC Data Exchange Format
ā¢ NFC Forum
ā¢ Records can be MIME-type media, URIs or
RTDs (Record Type Deļ¬nitions)
1 *
Ndef-Tag NdefMessage NdefRecord
55. P2P: NDEF Push
ā¢ Create NDEF Message which is pushed to
another active device once the other
device is close
NfcAdapter.enableForegroundNdefPush(activity, ndefmessage)
NfcAdapter.disableForegroundNdefPush(activity)
56. about
Sven Haiges, hybris GmbH
Twitter @hansamann
Android, HTML5,
Groovy & Grails
sven.haiges@hybris.de
57. about
Sven Haiges, hybris GmbH
Twitter @hansamann
Android, HTML5,
Groovy & Grails
sven.haiges@hybris.de
NFC