SlideShare a Scribd company logo
1 of 31
Android NFC Workshop
@JamesElsey1986
@Smart421
Agenda
1. Overview of tags and NDEF
a. Types of tags
b. Tag Dispatch System
c. Different NDEF messages
d. Legacy tags
2. Read a plain text tag
3. Write a plain text tag
4. Write a URI tag
5. Android application records (AAR)
6. Beaming data between devices
What is an NFC tag?
NFC Forum
Types of NFC Tag
Type 1 Tag Type 2 Tag Type 3 Tag Type 4 Tag
Compatible Products Broadcom
Topaz
NXP Mifare
Ultralight, NXP
Mifare Ultralight C,
NXP NTAG203
Sony FeliCa NXP DESFire / NXP
SmartMX-JCOP
Memory Size 96 Bytes 48 Bytes / 144
Bytes
1, 4, 9 KB 4 KB /32 KB
Unit Price Low Low High Medium I High
Data Access Read/Write or
Read-Only
Read/Write or
Read-Only
Read/Write or
Read-Only
Read/Write or Read-
Only
source: http://www.nfctags.com/nfc-applications-which-tag
Variations of Type 2 tags
Source : http://rapidnfc.com/which_nfc_chip
Ultralight Ultralight C NTAG203
Memory Size 64 bytes 192 bytes 168 bytes
User Memory 46 bytes 137 bytes 137 bytes
URL Length 41 chars 132 chars 132 chars
Text Length 39 chars 130 chars 130 chars
Best Use Cost effective,
short URL,
smart poster and
general NFC
use.
For applications
required
encryption tech
only.
Latest chip, best
performance.
Great for
everything from
marketing to
task launcher
apps.
Cost £0.40 £0.80 £0.40
NDEF
Tag Dispatch System
What happens when a tag is detected?
1.Analyse the tag
2.Categorise the data
3.Start an application that is interested in the
categorised data
Applications declare intent filters to request the
ability to handle the data
Tag Dispatch System
Enabling NFC in your app
1. Request permission to the NFC hardware
o <uses-permission android:name="android.permission.NFC" />
1. Set SDK level
o <uses-sdk android:minSdkVersion="10"/>
1. (optionally) Set uses feature so app only shows on Google Play if the
device has NFC hardware
o <uses-feature android:name="android.hardware.nfc"
android:required="true" />
Reading a plain text tag
1. Grab the intent
2. Check if action is
ACTION_NDEF_DISCOVERED
3. Get EXTRA_NDEF_MESSAGES from the
extras bundle
1. Extract the payloads from the NdefRecords
Reading a plain text tag
(demo time)
Writing a tag
byte[] langBytes = locale.getLanguage().getBytes(Charset.forName("US-ASCII"));
Charset utfEncoding = encodeInUtf8 ? Charset.forName("UTF-8") : Charset.forName("UTF-16");
byte[] textBytes = payload.getBytes(utfEncoding);
int utfBit = encodeInUtf8 ? 0 : (1 << 7);
char status = (char) (utfBit + langBytes.length);
byte[] data = new byte[1 + langBytes.length + textBytes.length];
data[0] = (byte) status;
System.arraycopy(langBytes, 0, data, 1, langBytes.length);
System.arraycopy(textBytes, 0, data, 1 + langBytes.length, textBytes.length);
return new NdefRecord(NdefRecord.TNF_WELL_KNOWN,
NdefRecord.RTD_TEXT, new byte[0], data);
}
private NdefRecord createTextRecord(String payload, Locale locale, boolean encodeInUtf8) {
Write a plain text tag
(demotime!)
Write a URI to a tag
• Same as plain text
• Use RTD_URI instead of RTD_TEXT
Write protecting a tag
Formatted Tags:
ndef.connect();
ndef.writeNdefMessage(message);
ndef.makeReadOnly()
Make read only during format:
format.connect();
format.formatReadOnly(message);
Android Application Records
• Introduced in 4.0
• Ensures application is opened if available
• Directs to marketplace if not installed
NdefRecord.createApplicationRecord(
"com.example.android.beam”)
Android Application Records
(demo time)
Google I/O 2011 - How to NFC
http://www.youtube.com/watch?v=49L7z3rxz4Q
Beaming Data between devices
Best Practices
• Avoid intent chooser!
• Write protect tags where possible
• Move the NFC read/writing off the main
thread
• Use a wrapper such as Ndef tools for
android
Resources
Android SDK docs for NFC
http://developer.android.com/guide/topics/connectivity/nfc/nfc.html
Google I/O NFC video
http://www.youtube.com/watch?v=49L7z3rxz4Q
Excellent overview on NDEF standards http://
ibadrinath.blogspot.co.uk/2012/07/nfc-data-exchange-format-ndef.html
NDEF Tools for Android
https://code.google.com/p/ndef-tools-for-android/
Usages of NFC?
• At work
• In the car
• In your wallet
• In the gym
& more!
Where to get NFC Tags?
• http://rapidnfc.com/
QA
Thanks for attending!
@jameselsey1986

More Related Content

What's hot

Rfid security workshop v0.9 -nahuel_grisolia
Rfid security workshop v0.9  -nahuel_grisoliaRfid security workshop v0.9  -nahuel_grisolia
Rfid security workshop v0.9 -nahuel_grisoliaPositive Hack Days
 
NFCRFID Ripe for Application Expansion_ElectronicDesign
NFCRFID Ripe for Application Expansion_ElectronicDesignNFCRFID Ripe for Application Expansion_ElectronicDesign
NFCRFID Ripe for Application Expansion_ElectronicDesignHamed M. Sanogo
 
ACR128 product presentation by Advanced Card Systems Ltd.
ACR128 product presentation by Advanced Card Systems Ltd.ACR128 product presentation by Advanced Card Systems Ltd.
ACR128 product presentation by Advanced Card Systems Ltd.Advanced Card Systems Ltd.
 
Bluetooth Secure Simple Pairing Using NFC Part 1
Bluetooth Secure Simple Pairing Using NFC Part 1 Bluetooth Secure Simple Pairing Using NFC Part 1
Bluetooth Secure Simple Pairing Using NFC Part 1 NFC Forum
 
Lp 2010 operation-theory
Lp 2010 operation-theoryLp 2010 operation-theory
Lp 2010 operation-theoryNguyen Duc Anh
 
NFC Technology
NFC TechnologyNFC Technology
NFC TechnologyNeha Singh
 
Other types of networks: Bluetooth, Zigbee, & NFC
Other types of networks: Bluetooth, Zigbee, & NFCOther types of networks: Bluetooth, Zigbee, & NFC
Other types of networks: Bluetooth, Zigbee, & NFCDilum Bandara
 
DefCon 2012 - Near-Field Communication / RFID Hacking - Miller
DefCon 2012 - Near-Field Communication / RFID Hacking - MillerDefCon 2012 - Near-Field Communication / RFID Hacking - Miller
DefCon 2012 - Near-Field Communication / RFID Hacking - MillerMichael Smith
 
2008 07 - ss - near field communication
2008 07 - ss - near field communication2008 07 - ss - near field communication
2008 07 - ss - near field communicationBoni
 
RFID Update for National Acquisitions Group Conference, York 2013
RFID Update for National Acquisitions Group Conference, York 2013RFID Update for National Acquisitions Group Conference, York 2013
RFID Update for National Acquisitions Group Conference, York 2013Michael Fortune
 
Windows (Phone) 8 NFC App Scenarios
Windows (Phone) 8 NFC App ScenariosWindows (Phone) 8 NFC App Scenarios
Windows (Phone) 8 NFC App ScenariosAndreas Jakl
 
NEAR FIELD COMMUNICATION
NEAR FIELD COMMUNICATIONNEAR FIELD COMMUNICATION
NEAR FIELD COMMUNICATIONavtechno
 

What's hot (20)

Rfid security workshop v0.9 -nahuel_grisolia
Rfid security workshop v0.9  -nahuel_grisoliaRfid security workshop v0.9  -nahuel_grisolia
Rfid security workshop v0.9 -nahuel_grisolia
 
NFCRFID Ripe for Application Expansion_ElectronicDesign
NFCRFID Ripe for Application Expansion_ElectronicDesignNFCRFID Ripe for Application Expansion_ElectronicDesign
NFCRFID Ripe for Application Expansion_ElectronicDesign
 
Overview chip
Overview chipOverview chip
Overview chip
 
Nullcon 2011 RFID - NÂO ENVIADO AO EVENTO
Nullcon 2011   RFID - NÂO ENVIADO AO EVENTONullcon 2011   RFID - NÂO ENVIADO AO EVENTO
Nullcon 2011 RFID - NÂO ENVIADO AO EVENTO
 
ACR128 product presentation by Advanced Card Systems Ltd.
ACR128 product presentation by Advanced Card Systems Ltd.ACR128 product presentation by Advanced Card Systems Ltd.
ACR128 product presentation by Advanced Card Systems Ltd.
 
Nfc
NfcNfc
Nfc
 
Bluetooth Secure Simple Pairing Using NFC Part 1
Bluetooth Secure Simple Pairing Using NFC Part 1 Bluetooth Secure Simple Pairing Using NFC Part 1
Bluetooth Secure Simple Pairing Using NFC Part 1
 
Lp 2010 operation-theory
Lp 2010 operation-theoryLp 2010 operation-theory
Lp 2010 operation-theory
 
Talk-ID Engels (1)
Talk-ID Engels (1)Talk-ID Engels (1)
Talk-ID Engels (1)
 
NFC Technology
NFC TechnologyNFC Technology
NFC Technology
 
Cours NFC 2019
Cours NFC 2019Cours NFC 2019
Cours NFC 2019
 
10.1
10.110.1
10.1
 
It nfc presentation
It nfc presentationIt nfc presentation
It nfc presentation
 
Other types of networks: Bluetooth, Zigbee, & NFC
Other types of networks: Bluetooth, Zigbee, & NFCOther types of networks: Bluetooth, Zigbee, & NFC
Other types of networks: Bluetooth, Zigbee, & NFC
 
DefCon 2012 - Near-Field Communication / RFID Hacking - Miller
DefCon 2012 - Near-Field Communication / RFID Hacking - MillerDefCon 2012 - Near-Field Communication / RFID Hacking - Miller
DefCon 2012 - Near-Field Communication / RFID Hacking - Miller
 
2008 07 - ss - near field communication
2008 07 - ss - near field communication2008 07 - ss - near field communication
2008 07 - ss - near field communication
 
RFID Update for National Acquisitions Group Conference, York 2013
RFID Update for National Acquisitions Group Conference, York 2013RFID Update for National Acquisitions Group Conference, York 2013
RFID Update for National Acquisitions Group Conference, York 2013
 
Windows (Phone) 8 NFC App Scenarios
Windows (Phone) 8 NFC App ScenariosWindows (Phone) 8 NFC App Scenarios
Windows (Phone) 8 NFC App Scenarios
 
NEAR FIELD COMMUNICATION
NEAR FIELD COMMUNICATIONNEAR FIELD COMMUNICATION
NEAR FIELD COMMUNICATION
 
Near field communication
Near field communicationNear field communication
Near field communication
 

Viewers also liked

Nfc reader writer_mode
Nfc reader writer_modeNfc reader writer_mode
Nfc reader writer_modeChun-Kai Wang
 
Android Application Development of NFC Reader-Writer Mode
Android Application Development of NFC Reader-Writer ModeAndroid Application Development of NFC Reader-Writer Mode
Android Application Development of NFC Reader-Writer ModeChun-Kai Wang
 
Embedded Systems Security News 2011/05
Embedded Systems Security News 2011/05Embedded Systems Security News 2011/05
Embedded Systems Security News 2011/05AurMiana
 
NFC (Windows 8/ Windows Phone 8 )
NFC (Windows 8/ Windows Phone 8 )NFC (Windows 8/ Windows Phone 8 )
NFC (Windows 8/ Windows Phone 8 )Bill Chung
 
Standards for the Future of Java Embedded (16:9)
Standards for the Future of Java Embedded (16:9)Standards for the Future of Java Embedded (16:9)
Standards for the Future of Java Embedded (16:9)Werner Keil
 
geecon 2013 - Standards for the Future of Java Embedded
geecon 2013 - Standards for the Future of Java Embeddedgeecon 2013 - Standards for the Future of Java Embedded
geecon 2013 - Standards for the Future of Java EmbeddedWerner Keil
 
Track 2 session 3 - st dev con 2016 - simplifying cloud connectivity
Track 2   session 3 - st dev con 2016 - simplifying cloud connectivityTrack 2   session 3 - st dev con 2016 - simplifying cloud connectivity
Track 2 session 3 - st dev con 2016 - simplifying cloud connectivityST_World
 
DevBy. Apple Watch Kit 1.0 (RU) & NFC
DevBy. Apple Watch Kit 1.0 (RU) & NFCDevBy. Apple Watch Kit 1.0 (RU) & NFC
DevBy. Apple Watch Kit 1.0 (RU) & NFCVladimir Hudnitsky
 
The Eclipse M2M IWG and Standards for the Internet of Things
The Eclipse M2M IWG and Standards for the Internet of ThingsThe Eclipse M2M IWG and Standards for the Internet of Things
The Eclipse M2M IWG and Standards for the Internet of ThingsWerner Keil
 
DASH7 Alliance Protocol 1.0: Low-Power, Mid-Range Sensor and Actuator Communi...
DASH7 Alliance Protocol 1.0: Low-Power, Mid-Range Sensor and Actuator Communi...DASH7 Alliance Protocol 1.0: Low-Power, Mid-Range Sensor and Actuator Communi...
DASH7 Alliance Protocol 1.0: Low-Power, Mid-Range Sensor and Actuator Communi...Maarten Weyn
 
Latest wireless technology
Latest wireless technologyLatest wireless technology
Latest wireless technologynurmeen1
 
OPTIMOS Interoperability Event - Introduction to the Interoperability Initiative
OPTIMOS Interoperability Event - Introduction to the Interoperability InitiativeOPTIMOS Interoperability Event - Introduction to the Interoperability Initiative
OPTIMOS Interoperability Event - Introduction to the Interoperability InitiativeNFC Forum
 
Introduction to the Interoperability Initiative
Introduction to the Interoperability InitiativeIntroduction to the Interoperability Initiative
Introduction to the Interoperability InitiativeNFC Forum
 
Transit Ticketing and Fare Collection Conference - Introduction to the Intero...
Transit Ticketing and Fare Collection Conference - Introduction to the Intero...Transit Ticketing and Fare Collection Conference - Introduction to the Intero...
Transit Ticketing and Fare Collection Conference - Introduction to the Intero...NFC Forum
 
便利なNFC ~利用シーンと技術の動向~
便利なNFC  ~利用シーンと技術の動向~便利なNFC  ~利用シーンと技術の動向~
便利なNFC ~利用シーンと技術の動向~NFC Forum
 
NFC Mobile Payments 2016 What’s Next?
NFC Mobile Payments 2016 What’s Next?NFC Mobile Payments 2016 What’s Next?
NFC Mobile Payments 2016 What’s Next?NFC Forum
 
Near Field Communication in m-Commerce
Near Field Communication in m-CommerceNear Field Communication in m-Commerce
Near Field Communication in m-CommerceThejasK8
 
RFID2015_NFC-WISP_public(delete Disney research)
RFID2015_NFC-WISP_public(delete Disney research)RFID2015_NFC-WISP_public(delete Disney research)
RFID2015_NFC-WISP_public(delete Disney research)Yi (Eve) Zhao
 

Viewers also liked (20)

Nfc reader writer_mode
Nfc reader writer_modeNfc reader writer_mode
Nfc reader writer_mode
 
Android Application Development of NFC Reader-Writer Mode
Android Application Development of NFC Reader-Writer ModeAndroid Application Development of NFC Reader-Writer Mode
Android Application Development of NFC Reader-Writer Mode
 
Embedded Systems Security News 2011/05
Embedded Systems Security News 2011/05Embedded Systems Security News 2011/05
Embedded Systems Security News 2011/05
 
NFC (Windows 8/ Windows Phone 8 )
NFC (Windows 8/ Windows Phone 8 )NFC (Windows 8/ Windows Phone 8 )
NFC (Windows 8/ Windows Phone 8 )
 
Sensor id overview_ppt
Sensor id overview_pptSensor id overview_ppt
Sensor id overview_ppt
 
Standards for the Future of Java Embedded (16:9)
Standards for the Future of Java Embedded (16:9)Standards for the Future of Java Embedded (16:9)
Standards for the Future of Java Embedded (16:9)
 
geecon 2013 - Standards for the Future of Java Embedded
geecon 2013 - Standards for the Future of Java Embeddedgeecon 2013 - Standards for the Future of Java Embedded
geecon 2013 - Standards for the Future of Java Embedded
 
Track 2 session 3 - st dev con 2016 - simplifying cloud connectivity
Track 2   session 3 - st dev con 2016 - simplifying cloud connectivityTrack 2   session 3 - st dev con 2016 - simplifying cloud connectivity
Track 2 session 3 - st dev con 2016 - simplifying cloud connectivity
 
DevBy. Apple Watch Kit 1.0 (RU) & NFC
DevBy. Apple Watch Kit 1.0 (RU) & NFCDevBy. Apple Watch Kit 1.0 (RU) & NFC
DevBy. Apple Watch Kit 1.0 (RU) & NFC
 
The Eclipse M2M IWG and Standards for the Internet of Things
The Eclipse M2M IWG and Standards for the Internet of ThingsThe Eclipse M2M IWG and Standards for the Internet of Things
The Eclipse M2M IWG and Standards for the Internet of Things
 
DASH7 Alliance Protocol 1.0: Low-Power, Mid-Range Sensor and Actuator Communi...
DASH7 Alliance Protocol 1.0: Low-Power, Mid-Range Sensor and Actuator Communi...DASH7 Alliance Protocol 1.0: Low-Power, Mid-Range Sensor and Actuator Communi...
DASH7 Alliance Protocol 1.0: Low-Power, Mid-Range Sensor and Actuator Communi...
 
Latest wireless technology
Latest wireless technologyLatest wireless technology
Latest wireless technology
 
OPTIMOS Interoperability Event - Introduction to the Interoperability Initiative
OPTIMOS Interoperability Event - Introduction to the Interoperability InitiativeOPTIMOS Interoperability Event - Introduction to the Interoperability Initiative
OPTIMOS Interoperability Event - Introduction to the Interoperability Initiative
 
NFC and Android applications
NFC and Android applicationsNFC and Android applications
NFC and Android applications
 
Introduction to the Interoperability Initiative
Introduction to the Interoperability InitiativeIntroduction to the Interoperability Initiative
Introduction to the Interoperability Initiative
 
Transit Ticketing and Fare Collection Conference - Introduction to the Intero...
Transit Ticketing and Fare Collection Conference - Introduction to the Intero...Transit Ticketing and Fare Collection Conference - Introduction to the Intero...
Transit Ticketing and Fare Collection Conference - Introduction to the Intero...
 
便利なNFC ~利用シーンと技術の動向~
便利なNFC  ~利用シーンと技術の動向~便利なNFC  ~利用シーンと技術の動向~
便利なNFC ~利用シーンと技術の動向~
 
NFC Mobile Payments 2016 What’s Next?
NFC Mobile Payments 2016 What’s Next?NFC Mobile Payments 2016 What’s Next?
NFC Mobile Payments 2016 What’s Next?
 
Near Field Communication in m-Commerce
Near Field Communication in m-CommerceNear Field Communication in m-Commerce
Near Field Communication in m-Commerce
 
RFID2015_NFC-WISP_public(delete Disney research)
RFID2015_NFC-WISP_public(delete Disney research)RFID2015_NFC-WISP_public(delete Disney research)
RFID2015_NFC-WISP_public(delete Disney research)
 

Similar to Android NFC Workshop MobDevCon 2013

NFC Bootcamp Seattle Day 2
NFC Bootcamp Seattle Day 2 NFC Bootcamp Seattle Day 2
NFC Bootcamp Seattle Day 2 traceebeebe
 
Porting Android ABS 2011
Porting Android ABS 2011Porting Android ABS 2011
Porting Android ABS 2011Opersys inc.
 
Near field communication (NFC) in android
Near field communication (NFC) in androidNear field communication (NFC) in android
Near field communication (NFC) in androidMindfire Solutions
 
Breaking New Frontiers in Robotics and Edge Computing with AI
Breaking New Frontiers in Robotics and Edge Computing with AIBreaking New Frontiers in Robotics and Edge Computing with AI
Breaking New Frontiers in Robotics and Edge Computing with AIDustin Franklin
 
Republic of IoT - Hackathon Hardware Kits Hands-on Labs
Republic of IoT - Hackathon Hardware Kits Hands-on LabsRepublic of IoT - Hackathon Hardware Kits Hands-on Labs
Republic of IoT - Hackathon Hardware Kits Hands-on LabsAlwin Arrasyid
 
NFC & RFID on Android
NFC & RFID on AndroidNFC & RFID on Android
NFC & RFID on Androidtodbotdotcom
 
Introduction to NFC
Introduction to NFCIntroduction to NFC
Introduction to NFCWei-Tsung Su
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource KernelsSilvio Cesare
 
เทคโนโลยีสารสนเทศสำหรับครู
เทคโนโลยีสารสนเทศสำหรับครูเทคโนโลยีสารสนเทศสำหรับครู
เทคโนโลยีสารสนเทศสำหรับครูBeauso English
 
Android memory analysis Debug slides.pdf
Android memory analysis Debug slides.pdfAndroid memory analysis Debug slides.pdf
Android memory analysis Debug slides.pdfVishalKumarJha10
 
Wireless security testing with attack by Keiichi Horiai - CODE BLUE 2015
Wireless security testing with attack by Keiichi Horiai - CODE BLUE 2015Wireless security testing with attack by Keiichi Horiai - CODE BLUE 2015
Wireless security testing with attack by Keiichi Horiai - CODE BLUE 2015CODE BLUE
 
A New Framework for Detection
A New Framework for DetectionA New Framework for Detection
A New Framework for DetectionSourcefire VRT
 
NFC on Android - Near Field Communication
NFC on Android - Near Field CommunicationNFC on Android - Near Field Communication
NFC on Android - Near Field CommunicationSven Haiges
 
BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!Linaro
 

Similar to Android NFC Workshop MobDevCon 2013 (20)

NFC Bootcamp Seattle Day 2
NFC Bootcamp Seattle Day 2 NFC Bootcamp Seattle Day 2
NFC Bootcamp Seattle Day 2
 
Nfc on Android
Nfc on AndroidNfc on Android
Nfc on Android
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Porting Android ABS 2011
Porting Android ABS 2011Porting Android ABS 2011
Porting Android ABS 2011
 
Near field communication (NFC) in android
Near field communication (NFC) in androidNear field communication (NFC) in android
Near field communication (NFC) in android
 
AFPS_2011
AFPS_2011AFPS_2011
AFPS_2011
 
Breaking New Frontiers in Robotics and Edge Computing with AI
Breaking New Frontiers in Robotics and Edge Computing with AIBreaking New Frontiers in Robotics and Edge Computing with AI
Breaking New Frontiers in Robotics and Edge Computing with AI
 
Republic of IoT - Hackathon Hardware Kits Hands-on Labs
Republic of IoT - Hackathon Hardware Kits Hands-on LabsRepublic of IoT - Hackathon Hardware Kits Hands-on Labs
Republic of IoT - Hackathon Hardware Kits Hands-on Labs
 
NFC & RFID on Android
NFC & RFID on AndroidNFC & RFID on Android
NFC & RFID on Android
 
Introduction to NFC
Introduction to NFCIntroduction to NFC
Introduction to NFC
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Auditing the Opensource Kernels
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource Kernels
 
เทคโนโลยีสารสนเทศสำหรับครู
เทคโนโลยีสารสนเทศสำหรับครูเทคโนโลยีสารสนเทศสำหรับครู
เทคโนโลยีสารสนเทศสำหรับครู
 
Tos tutorial
Tos tutorialTos tutorial
Tos tutorial
 
Android memory analysis Debug slides.pdf
Android memory analysis Debug slides.pdfAndroid memory analysis Debug slides.pdf
Android memory analysis Debug slides.pdf
 
Wireless security testing with attack by Keiichi Horiai - CODE BLUE 2015
Wireless security testing with attack by Keiichi Horiai - CODE BLUE 2015Wireless security testing with attack by Keiichi Horiai - CODE BLUE 2015
Wireless security testing with attack by Keiichi Horiai - CODE BLUE 2015
 
A New Framework for Detection
A New Framework for DetectionA New Framework for Detection
A New Framework for Detection
 
NFC on Android - Near Field Communication
NFC on Android - Near Field CommunicationNFC on Android - Near Field Communication
NFC on Android - Near Field Communication
 
BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!BKK16-103 OpenCSD - Open for Business!
BKK16-103 OpenCSD - Open for Business!
 
4055-841_Project_ShailendraSadh
4055-841_Project_ShailendraSadh4055-841_Project_ShailendraSadh
4055-841_Project_ShailendraSadh
 

Recently uploaded

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingWSO2
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringWSO2
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuidePixlogix Infotech
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxMarkSteadman7
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....rightmanforbloodline
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformWSO2
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfdanishmna97
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 

Recently uploaded (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
WSO2 Micro Integrator for Enterprise Integration in a Decentralized, Microser...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Quantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation ComputingQuantum Leap in Next-Generation Computing
Quantum Leap in Next-Generation Computing
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Simplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptxSimplifying Mobile A11y Presentation.pptx
Simplifying Mobile A11y Presentation.pptx
 
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
TEST BANK For Principles of Anatomy and Physiology, 16th Edition by Gerard J....
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data PlatformLess Is More: Utilizing Ballerina to Architect a Cloud Data Platform
Less Is More: Utilizing Ballerina to Architect a Cloud Data Platform
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Android NFC Workshop MobDevCon 2013

  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. Agenda 1. Overview of tags and NDEF a. Types of tags b. Tag Dispatch System c. Different NDEF messages d. Legacy tags 2. Read a plain text tag 3. Write a plain text tag 4. Write a URI tag 5. Android application records (AAR) 6. Beaming data between devices
  • 8. What is an NFC tag?
  • 10. Types of NFC Tag Type 1 Tag Type 2 Tag Type 3 Tag Type 4 Tag Compatible Products Broadcom Topaz NXP Mifare Ultralight, NXP Mifare Ultralight C, NXP NTAG203 Sony FeliCa NXP DESFire / NXP SmartMX-JCOP Memory Size 96 Bytes 48 Bytes / 144 Bytes 1, 4, 9 KB 4 KB /32 KB Unit Price Low Low High Medium I High Data Access Read/Write or Read-Only Read/Write or Read-Only Read/Write or Read-Only Read/Write or Read- Only source: http://www.nfctags.com/nfc-applications-which-tag
  • 11. Variations of Type 2 tags Source : http://rapidnfc.com/which_nfc_chip Ultralight Ultralight C NTAG203 Memory Size 64 bytes 192 bytes 168 bytes User Memory 46 bytes 137 bytes 137 bytes URL Length 41 chars 132 chars 132 chars Text Length 39 chars 130 chars 130 chars Best Use Cost effective, short URL, smart poster and general NFC use. For applications required encryption tech only. Latest chip, best performance. Great for everything from marketing to task launcher apps. Cost £0.40 £0.80 £0.40
  • 12. NDEF
  • 13. Tag Dispatch System What happens when a tag is detected? 1.Analyse the tag 2.Categorise the data 3.Start an application that is interested in the categorised data Applications declare intent filters to request the ability to handle the data
  • 15. Enabling NFC in your app 1. Request permission to the NFC hardware o <uses-permission android:name="android.permission.NFC" /> 1. Set SDK level o <uses-sdk android:minSdkVersion="10"/> 1. (optionally) Set uses feature so app only shows on Google Play if the device has NFC hardware o <uses-feature android:name="android.hardware.nfc" android:required="true" />
  • 16. Reading a plain text tag 1. Grab the intent 2. Check if action is ACTION_NDEF_DISCOVERED 3. Get EXTRA_NDEF_MESSAGES from the extras bundle 1. Extract the payloads from the NdefRecords
  • 17. Reading a plain text tag (demo time)
  • 18. Writing a tag byte[] langBytes = locale.getLanguage().getBytes(Charset.forName("US-ASCII")); Charset utfEncoding = encodeInUtf8 ? Charset.forName("UTF-8") : Charset.forName("UTF-16"); byte[] textBytes = payload.getBytes(utfEncoding); int utfBit = encodeInUtf8 ? 0 : (1 << 7); char status = (char) (utfBit + langBytes.length); byte[] data = new byte[1 + langBytes.length + textBytes.length]; data[0] = (byte) status; System.arraycopy(langBytes, 0, data, 1, langBytes.length); System.arraycopy(textBytes, 0, data, 1 + langBytes.length, textBytes.length); return new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT, new byte[0], data); } private NdefRecord createTextRecord(String payload, Locale locale, boolean encodeInUtf8) {
  • 19. Write a plain text tag (demotime!)
  • 20. Write a URI to a tag • Same as plain text • Use RTD_URI instead of RTD_TEXT
  • 21. Write protecting a tag Formatted Tags: ndef.connect(); ndef.writeNdefMessage(message); ndef.makeReadOnly() Make read only during format: format.connect(); format.formatReadOnly(message);
  • 22. Android Application Records • Introduced in 4.0 • Ensures application is opened if available • Directs to marketplace if not installed NdefRecord.createApplicationRecord( "com.example.android.beam”)
  • 24. Google I/O 2011 - How to NFC http://www.youtube.com/watch?v=49L7z3rxz4Q
  • 26. Best Practices • Avoid intent chooser! • Write protect tags where possible • Move the NFC read/writing off the main thread • Use a wrapper such as Ndef tools for android
  • 27. Resources Android SDK docs for NFC http://developer.android.com/guide/topics/connectivity/nfc/nfc.html Google I/O NFC video http://www.youtube.com/watch?v=49L7z3rxz4Q Excellent overview on NDEF standards http:// ibadrinath.blogspot.co.uk/2012/07/nfc-data-exchange-format-ndef.html NDEF Tools for Android https://code.google.com/p/ndef-tools-for-android/
  • 28. Usages of NFC? • At work • In the car • In your wallet • In the gym & more!
  • 29. Where to get NFC Tags? • http://rapidnfc.com/
  • 30. QA

Editor's Notes

  1. My name is James Elsey, I ’ m a software developer at Smart421 working on a variety of enterprise java applications, and more recently mobile applications.
  2. I ’ m currently working at O2…
  3. … Working with this stuff
  4. … But secretly love doing this stuff
  5. Todays session will take just over an hour, we have a lot to get through, and time permitting we can achieve this. We have about 10 minutes of slides, and then will jump into some coding At the end of the session I ’ ll take QA, and provide links to the slides, source code, references, and my details should you have anything you want to ask me about Firstly we ’ ll cover some of the basics of NFC and the NDEF format, then we ’ ll jump in to reading/writing plain text tags. We ’ ll then have a look at writing URI tags. After that we ’ ll discuss a few of the NFC goodies that have been introduced with Ice cream sandwich such as android application records for ensuring that your app is launched or downloaded, and then beaming data between devices. AAR for zxing : com.google.zxing.client.android
  6. So, what is an NFC tag? They look very similar to RFID tags that you may have seen on the back of CDs and DVDs whilst browsing at your favourite music store. They often come in sticker format but you can also buy wristbands, keyrings, business cards etc with NFC tags embedded. NFC != RFID RFID has a greater range , meters rather than centimeters RFID is one way, you read a tag and that is it NFC 3 modes: Read/write – for tags Peer to peer – Android beaming. 4.1 jelly bean introduced advanced beaming where a bluetooth connection is established to transfer more data Card Emulation
  7. In 2004 Sony, Nokia and Phillips founded the NFC forum Now has over 170 members, including : Google Intel HP LG Various financial companies Visa Barclaycard American Express Mastercard Proxama are also a member of the forum
  8. In 2007 the NFC Forum published the specification for 4 types of NFC tags. The key differences between the tags are their memory sizes and read/write speeds. Probably most likely to use type 2 tags Type 2 tags come in 2 flavours, 48 bytes and 144 bytes. The white tags are type2 144. Usages Type 1 - Type 2 - Mifare Ultralight – Cheap and often disposable, used in Football world cup 2006 Germany - NTAG203, according to ZipNFC (sellers) is by far the most popular tag. Type 3 – Type 4 - NXP DESFire – Oyster card (was using Mifare classic)
  9. As you can see there are some variations of type 2 tags. The ultralight tags generally speaking wont have enough space to store an AAR unless the package name is really short. NTAG203’s are the white round stickers, they’re good general purpose tags with enough capacity to store AARs and urls.
  10. There are typically 1 NDEF Message in a tag and for the most part you can safely work against this assumption The NDEF message may have multiple NDEF Records in a tag Identifier - Rarely used, but can be used to uniquely identify your tag 3-bit TNF (Type Name Format) Indicates how to interpret the variable length type field. Valid values are described in described in Table 1 . such as TNF_WELL_KNOWN or TNF_MIME_MEDIA Variable length type Describes the type of the record. If using TNF_WELL_KNOWN , use this field to specify the Record Type Definition (RTD). Valid RTD values are described in Table 2 . such as RTD_URI or RTD_TEXT Variable length ID A unique identifier for the record. This field is not used often, but if you need to uniquely identify a tag, you can create an ID for it. Variable length payload The actual data payload that you want to read or write. An NDEF message can contain multiple NDEF records, so don&apos;t assume the full payload is in the first NDEF record of the NDEF message.
  11. Responsible for working out what to do with a tag when it is discovered Parsing the NFC tag and figuring out the MIME type or a URI that identifies the data payload in the tag. Encapsulating the MIME type or URI and the payload into an intent. These first two steps are described in How NFC tags are mapped to MIME types and URIs . Starts an activity based on the intent. This is described in How NFC Tags are Dispatched to Applications .
  12. IF an NDEF tag is discovered, android checks to see if anything is registered to handle NDEF discovered, otherwise it checks TECH_DISCOVERED
  13. Firstly you need to add the uses-permission into the manifest to request usage of the hardware Next you need to set the minSDK level (2.3 - 2.3.2 Gingerbread) - API level 9 only supports limited tag dispatch via ACTION_TAG_DISCOVERED , and only gives access to NDEF messages via the EXTRA_NDEF_MESSAGES extra. No other tag properties or I/O operations are accessible. (2.3.3 - 2.3.4 Gingerbread MR1) - API level 10 includes comprehensive reader/writer support as well as foreground NDEF pushing (4.0 - 4.0.2 Ice Cream Sandwich) - API level 14 provides an easier way to push NDEF messages to other devices with Android Beam and extra convenience methods to create NDEF records. Lastly, you can optionally set : &lt;uses-feature android:name=&quot;android.hardware.nfc&quot; android:required=&quot;true&quot; /&gt; This means that only devices with NFC hardware can download your app from the app store, you may like to omit this if NFC isn&apos;t critical to your app
  14. Grab the intent, we need to see the intent that invoked our application, was it a launcher? Was it a tag? Check if the intent has the action of ACTION_NDEF_DISCOVERED, if its not, we ’ re not interested Get the ndef messages from the extras bundle and then begin to extract the payloads
  15. Use android studio, cutting edge IDE released during Google I/O 2013 (early access preview however) Create a new project via the wizard, may have to fiddle with setup values or move project around after creating in an empty directory Setup manifest: &lt;uses-permission android:name=&quot;android.permission.NFC&quot; /&gt; (this should be put in by the project wizard) &lt;uses-sdk android:minSdkVersion=&quot;10&quot;/&gt; Deploy app to device Scan a tag Notice how it displays the activity chooser - This is a massive NOOB ERROR and completely goes against the principle of simplicity for NFC Create an activity to handle plain text tags Add this into manifest &lt;activity android:name=&quot;com.mobdevcon.nfckickstarter.PlainTextTagReader&quot;&gt; &lt;intent-filter&gt; &lt;action android:name=&quot;android.nfc.action.NDEF_DISCOVERED&quot;/&gt; &lt;category android:name=&quot;android.intent.category.DEFAULT&quot;/&gt; &lt;data android:mimeType=&quot;text/plain&quot;/&gt; &lt;/intent-filter&gt; &lt;/activity&gt; Scan again and notice how the app now loads for a plain text tag Explain how the activity starts, then we check intent for action, then check extras and begin to decode the messages
  16. Same process for writing the tag as the plain text example Only different is the RTD
  17. Check if application is already installed by searching for package name If installed, invoke the application If not installed, direct to app on market place Excellent mechanism for promoting your app via tags (conferences etc) Embed an android application record into the ndef message
  18. Show how to use
  19. AAR working ok? That means you should have ZXing, great, now bookmark this to read on the train home later : Youtube google i/o video
  20. Beaming is basically Peer to peer NFC, which was introduced in Ice cream sandwich. Used for exchange of data between android devices Very useful for exchanging data between the same application running on multiple devices, such as sharing contacts and urls. The application receiving the beam must be in the foreground, and the device not locked When the devices come in close contact, the “ touch to beam ” ui is displayed Relatively simple to use in comparison to existing NFC topics we ’ ve covered
  21. Avoid the intent chooser, the idea of nfc is to be quick and seamless Write protect tags where possible to prevent hijacking Rule of thumb, i/o should not be on the main thread! Use wrapper libraries such as Ndef tools to avoid using such low level APIs.
  22. at work Put an nfc on your laptop, that enables silent mode, turns on wifi In the car Put an nfc sticker on the dash, enables GPS and bluetooth In your wallet Run out of business cards? Ready made vCard good to go In the gym Create an nfc keyring that enables airplane mode and starts your favourite playlist
  23. You’re probably all thinking “where can I get some tags from”? We’ve bought from rapid nfc and have found them to be good (disclaimer, we’re not connected with RapidNfc in any way, just found them to be a good place to get tags from!) http://rapidnfc.com/ Feel free to take away the place mats for your own use too.