SlideShare a Scribd company logo
1 of 37
Speaker: 陳柏伸
GitHub: https://github.com/matisse11235813/AndroidNFC
NFC Tutorial
Outline
• Background knowledge
• DEMO
• 實作一個NFC Tag Reader
• 實作一個NFC Tag Writer
• 小結
• References
Near Field Communication,NFC
• 近場通訊(英語:Near Field Communication,NFC),又稱近距
離無線通訊,是一種短距離的高頻無線通訊技術,允許電子裝置
之間進行非接觸式點對點資料傳輸,在十公分(3.9英吋)內交換
資料。
• 這個技術由非接觸式射頻識別(RFID)演變而來,由飛利浦半導
體(現恩智浦半導體)、諾基亞和索尼共同研製開發。
不同通訊技術比較
近場通訊是一種短距高頻的無線電技
術,在13.56MHz頻率運行。其傳輸速
度最高可達424 Kbit/秒。目前近場通
訊已通過成為ISO/IEC IS 18092國際標
準、EMCA-340標準與ETSI TS 102 190
標準。
NFC的工作模式
• NFC 卡片模擬模式 (card emulation mode)
• 點對點模式 (peer-to-peer mode)
• 讀寫模式 (reader/writer mode)
NFC 卡片模擬模式
• NFC 可模擬 RFID 機體電路 (IC) 卡,搭配安全模組,可讓使用者安
全地進行交易。可以替代現在大量的IC卡(包括信用卡)場合商
場刷卡、IPASS、門禁管制、車票、門票等等。
點對點模式
• 可透過 NFC 連線在不同的 NFC 裝置之間分享名片等資訊。也能透
過 NFC 連線快速設定 WiFi* 或藍牙*連線,再以 WiFi 或藍牙連線
傳送大型檔案。
• Android Beam
• Samsung S Beam
• 市面上各種藍芽音響
讀寫模式
• 使用NFC Tag啟動NFC裝置的一些動作,或從海報或者展覽資訊電
子標籤上讀取相關資訊。
• 跟QR CODE比較
NFC Reader/Writer mode
Live DEMO
實作
NFC Tag Reader
<uses-permission>
• 在 AndroidManifest.xml裡加上下面這段,讓系統允許app去控制
NFC的硬體。
• <uses-permission android:name="android.permission.NFC" />
<uses-sdk>
• 在 AndroidManifest.xml,因為api level 10以上才支援對NFC Tag的
讀寫功能。
• <uses-sdk android:minSdkVersion="10" />
NFC Tag支援的資料格式
Android has the most support for the NDEF
standard
• The data stored in the tag can also be written in a variety of formats,
but many of the Android framework APIs are based around a NFC
Forumstandard called NDEF (NFC Data Exchange Format).
• Android has the most support for the NDEF standard, which is
defined by the NFC Forum.
NDEF
NDEF data is
encapsulated inside a
message (NdefMessage)
that contains one or
more records
(NdefRecord). Each
NDEF record must be
well-formed according
to the specification of
the type of record that
you want to create.
Obtaining information from intents
• If an activity starts because of an NFC intent, you can obtain
information about the scanned NFC tag from the intent.
• NdefMessage被封裝在intent裡面,activity 就是透過tag 所傳的
intent被trigger起來。
The Tag Dispatch System
<intent-filter>
Layout Design
在onResume時做動作
自訂方法: getNdefMessages
自訂方法: setNoteBody
實作
NFC Tag Writer
<uses-permission>
• 在 AndroidManifest.xml裡加上下面這段,讓系統允許app去控制
NFC的硬體。
• <uses-permission android:name="android.permission.NFC" />
<uses-sdk>
• 在 AndroidManifest.xml,因為api level 10以上才支援對NFC Tag的
讀寫功能。
• <uses-sdk android:minSdkVersion="10" />
UI設計
NfcAdapter
OnClickListener()
enableForegroundDispatch()
onNewIntent()
NDEF
NDEF data is
encapsulated inside a
message (NdefMessage)
that contains one or
more records
(NdefRecord). Each
NDEF record must be
well-formed according
to the specification of
the type of record that
you want to create.
小結
• 優缺點
References
• Android* 上的 NFC 應用程式開發 (多件個案研究) - Intel Dev Zone
• NFC on Android
• Android - 學習操作NFC – 1
• Android - 學習操作NFC – 2
• 近場通訊 - wiki

More Related Content

What's hot

Scan life 二維條碼
Scan life 二維條碼Scan life 二維條碼
Scan life 二維條碼yichieh20
 
Rfid(無線射頻辨識系統)
Rfid(無線射頻辨識系統)Rfid(無線射頻辨識系統)
Rfid(無線射頻辨識系統)mycute
 
2.3 g:4g usim 卡的安全性分析
2.3 g:4g usim 卡的安全性分析2.3 g:4g usim 卡的安全性分析
2.3 g:4g usim 卡的安全性分析Hsiao Tim
 
中國移動通信研究院Nfc swp現場支付培訓材料
中國移動通信研究院Nfc swp現場支付培訓材料中國移動通信研究院Nfc swp現場支付培訓材料
中國移動通信研究院Nfc swp現場支付培訓材料郭 茂仁
 
201112 ml-專題
201112 ml-專題201112 ml-專題
201112 ml-專題郭 茂仁
 
【物聯網自造x開發工具系列】Llinkit-7697物聯網實作開發案例-LoRa建置
【物聯網自造x開發工具系列】Llinkit-7697物聯網實作開發案例-LoRa建置【物聯網自造x開發工具系列】Llinkit-7697物聯網實作開發案例-LoRa建置
【物聯網自造x開發工具系列】Llinkit-7697物聯網實作開發案例-LoRa建置MAKERPRO.cc
 
Android作業系統移植之智慧電視整合平台
Android作業系統移植之智慧電視整合平台Android作業系統移植之智慧電視整合平台
Android作業系統移植之智慧電視整合平台艾鍗科技
 
硬件在安全领域的应用
硬件在安全领域的应用硬件在安全领域的应用
硬件在安全领域的应用renren-security
 
嵌入式 RFID 打卡系統
嵌入式 RFID 打卡系統嵌入式 RFID 打卡系統
嵌入式 RFID 打卡系統艾鍗科技
 
台灣發展雙網手機的可行性
台灣發展雙網手機的可行性台灣發展雙網手機的可行性
台灣發展雙網手機的可行性arcspoon
 
441 网思商业计划书
441 网思商业计划书441 网思商业计划书
441 网思商业计划书Rui (Nash) Yang
 

What's hot (17)

Scan life 二維條碼
Scan life 二維條碼Scan life 二維條碼
Scan life 二維條碼
 
Rfid(無線射頻辨識系統)
Rfid(無線射頻辨識系統)Rfid(無線射頻辨識系統)
Rfid(無線射頻辨識系統)
 
2.3 g:4g usim 卡的安全性分析
2.3 g:4g usim 卡的安全性分析2.3 g:4g usim 卡的安全性分析
2.3 g:4g usim 卡的安全性分析
 
Voip介绍
Voip介绍Voip介绍
Voip介绍
 
中國移動通信研究院Nfc swp現場支付培訓材料
中國移動通信研究院Nfc swp現場支付培訓材料中國移動通信研究院Nfc swp現場支付培訓材料
中國移動通信研究院Nfc swp現場支付培訓材料
 
201112 ml-專題
201112 ml-專題201112 ml-專題
201112 ml-專題
 
Warning door
Warning doorWarning door
Warning door
 
Warning door
Warning doorWarning door
Warning door
 
【物聯網自造x開發工具系列】Llinkit-7697物聯網實作開發案例-LoRa建置
【物聯網自造x開發工具系列】Llinkit-7697物聯網實作開發案例-LoRa建置【物聯網自造x開發工具系列】Llinkit-7697物聯網實作開發案例-LoRa建置
【物聯網自造x開發工具系列】Llinkit-7697物聯網實作開發案例-LoRa建置
 
iBeacons 簡介
iBeacons 簡介iBeacons 簡介
iBeacons 簡介
 
Android作業系統移植之智慧電視整合平台
Android作業系統移植之智慧電視整合平台Android作業系統移植之智慧電視整合平台
Android作業系統移植之智慧電視整合平台
 
硬件在安全领域的应用
硬件在安全领域的应用硬件在安全领域的应用
硬件在安全领域的应用
 
嵌入式 RFID 打卡系統
嵌入式 RFID 打卡系統嵌入式 RFID 打卡系統
嵌入式 RFID 打卡系統
 
台灣發展雙網手機的可行性
台灣發展雙網手機的可行性台灣發展雙網手機的可行性
台灣發展雙網手機的可行性
 
Warning door
Warning doorWarning door
Warning door
 
Warning door
Warning doorWarning door
Warning door
 
441 网思商业计划书
441 网思商业计划书441 网思商业计划书
441 网思商业计划书
 

Viewers also liked

Vodafone Cash Service - NFC tag
Vodafone Cash Service - NFC tagVodafone Cash Service - NFC tag
Vodafone Cash Service - NFC tagDeyaa Ahmed
 
Guide du tag NFC : quels usages dans quels contextes ?
Guide du tag NFC : quels usages dans quels contextes ?Guide du tag NFC : quels usages dans quels contextes ?
Guide du tag NFC : quels usages dans quels contextes ?Olivier Devillers
 
Contactless NFC Tags For Mobile Loyalty
Contactless NFC Tags For Mobile LoyaltyContactless NFC Tags For Mobile Loyalty
Contactless NFC Tags For Mobile LoyaltyMerchant360, Inc.
 
NFC Everywhere Brochure 2016
NFC Everywhere Brochure 2016NFC Everywhere Brochure 2016
NFC Everywhere Brochure 2016Laurent Dardé
 
Near Field Communication (NFC Architecture and Operating Modes)
Near Field Communication (NFC Architecture and Operating Modes)Near Field Communication (NFC Architecture and Operating Modes)
Near Field Communication (NFC Architecture and Operating Modes)Deepak Kl
 
Near field communication
Near field communicationNear field communication
Near field communicationNagesh Mishra
 
Nfc-Full Presentation
Nfc-Full PresentationNfc-Full Presentation
Nfc-Full PresentationDILIN RAJ DS
 
NFC(Near Field Communication)
NFC(Near Field Communication)NFC(Near Field Communication)
NFC(Near Field Communication)ADARSH KUMAR
 
Near field communication new
Near field communication newNear field communication new
Near field communication newSanu Varghese
 
RFID: a condensed overview
RFID: a condensed overviewRFID: a condensed overview
RFID: a condensed overviewMaarten Weyn
 
Track 4 session 5 - st dev con 2016 - simplifying the setup and use of iot ...
Track 4   session 5 - st dev con 2016 - simplifying the setup and use of iot ...Track 4   session 5 - st dev con 2016 - simplifying the setup and use of iot ...
Track 4 session 5 - st dev con 2016 - simplifying the setup and use of iot ...ST_World
 
NFC Development with Qt - v2.2.0 (5. November 2012)
NFC Development with Qt - v2.2.0 (5. November 2012)NFC Development with Qt - v2.2.0 (5. November 2012)
NFC Development with Qt - v2.2.0 (5. November 2012)Andreas Jakl
 
Near field communication(NFC)
Near field communication(NFC)Near field communication(NFC)
Near field communication(NFC)ronak1207
 
On Relaying NFC Payment Transactions using Android devices
On Relaying NFC Payment Transactions using Android devicesOn Relaying NFC Payment Transactions using Android devices
On Relaying NFC Payment Transactions using Android devicescgvwzq
 
Near field communication and RFID - opening for new business
Near field communication and RFID - opening for new businessNear field communication and RFID - opening for new business
Near field communication and RFID - opening for new businessJosef Noll
 
Near field communication
Near field communicationNear field communication
Near field communicationdivyasolanki101
 
Near Field Communication (NFC)
Near Field Communication (NFC)Near Field Communication (NFC)
Near Field Communication (NFC)Seminar Links
 

Viewers also liked (20)

Vodafone Cash Service - NFC tag
Vodafone Cash Service - NFC tagVodafone Cash Service - NFC tag
Vodafone Cash Service - NFC tag
 
Guide du tag NFC : quels usages dans quels contextes ?
Guide du tag NFC : quels usages dans quels contextes ?Guide du tag NFC : quels usages dans quels contextes ?
Guide du tag NFC : quels usages dans quels contextes ?
 
Contactless NFC Tags For Mobile Loyalty
Contactless NFC Tags For Mobile LoyaltyContactless NFC Tags For Mobile Loyalty
Contactless NFC Tags For Mobile Loyalty
 
NFC Everywhere Brochure 2016
NFC Everywhere Brochure 2016NFC Everywhere Brochure 2016
NFC Everywhere Brochure 2016
 
Near Field Communication (NFC Architecture and Operating Modes)
Near Field Communication (NFC Architecture and Operating Modes)Near Field Communication (NFC Architecture and Operating Modes)
Near Field Communication (NFC Architecture and Operating Modes)
 
Near field communication
Near field communicationNear field communication
Near field communication
 
Nfc-Full Presentation
Nfc-Full PresentationNfc-Full Presentation
Nfc-Full Presentation
 
Nfc technology ppt
Nfc technology pptNfc technology ppt
Nfc technology ppt
 
NFC(Near Field Communication)
NFC(Near Field Communication)NFC(Near Field Communication)
NFC(Near Field Communication)
 
Nfc kdr
Nfc kdrNfc kdr
Nfc kdr
 
Near field communication new
Near field communication newNear field communication new
Near field communication new
 
RFID: a condensed overview
RFID: a condensed overviewRFID: a condensed overview
RFID: a condensed overview
 
Track 4 session 5 - st dev con 2016 - simplifying the setup and use of iot ...
Track 4   session 5 - st dev con 2016 - simplifying the setup and use of iot ...Track 4   session 5 - st dev con 2016 - simplifying the setup and use of iot ...
Track 4 session 5 - st dev con 2016 - simplifying the setup and use of iot ...
 
NFC Development with Qt - v2.2.0 (5. November 2012)
NFC Development with Qt - v2.2.0 (5. November 2012)NFC Development with Qt - v2.2.0 (5. November 2012)
NFC Development with Qt - v2.2.0 (5. November 2012)
 
Nfc
NfcNfc
Nfc
 
Near field communication(NFC)
Near field communication(NFC)Near field communication(NFC)
Near field communication(NFC)
 
On Relaying NFC Payment Transactions using Android devices
On Relaying NFC Payment Transactions using Android devicesOn Relaying NFC Payment Transactions using Android devices
On Relaying NFC Payment Transactions using Android devices
 
Near field communication and RFID - opening for new business
Near field communication and RFID - opening for new businessNear field communication and RFID - opening for new business
Near field communication and RFID - opening for new business
 
Near field communication
Near field communicationNear field communication
Near field communication
 
Near Field Communication (NFC)
Near Field Communication (NFC)Near Field Communication (NFC)
Near Field Communication (NFC)
 

Similar to Nfc tutorial

twMVC#09 | RFID 與 NFC 在 Windows8/Windows Phone 8 開發概論
twMVC#09 | RFID 與 NFC 在 Windows8/Windows Phone 8 開發概論twMVC#09 | RFID 與 NFC 在 Windows8/Windows Phone 8 開發概論
twMVC#09 | RFID 與 NFC 在 Windows8/Windows Phone 8 開發概論twMVC
 
Android NFC Application Development Environment Setup
Android NFC Application Development Environment SetupAndroid NFC Application Development Environment Setup
Android NFC Application Development Environment SetupChun-Kai Wang
 
Nfc reader writer_mode
Nfc reader writer_modeNfc reader writer_mode
Nfc reader writer_modeChun-Kai Wang
 
组网实践
组网实践组网实践
组网实践telab
 
IoT感測器驅動程式在樹莓派上實作 IoT Sensor Driver On The Raspberry Pi
IoT感測器驅動程式在樹莓派上實作 IoT Sensor Driver On The Raspberry PiIoT感測器驅動程式在樹莓派上實作 IoT Sensor Driver On The Raspberry Pi
IoT感測器驅動程式在樹莓派上實作 IoT Sensor Driver On The Raspberry PiIttrainingIttraining
 
智慧家庭 簡報
智慧家庭 簡報智慧家庭 簡報
智慧家庭 簡報艾鍗科技
 
IoT感測器驅動程式 在樹莓派上實作
IoT感測器驅動程式在樹莓派上實作IoT感測器驅動程式在樹莓派上實作
IoT感測器驅動程式 在樹莓派上實作艾鍗科技
 
04 hou ziqiang
04 hou ziqiang04 hou ziqiang
04 hou ziqiangMason Mei
 
防火墙产品原理介绍20080407
防火墙产品原理介绍20080407防火墙产品原理介绍20080407
防火墙产品原理介绍20080407paulqi
 
05 zhao huiling
05 zhao huiling05 zhao huiling
05 zhao huilingMason Mei
 
LASS 2018 使用者與開發者大會 物聯網私有雲與環境監測
LASS 2018 使用者與開發者大會 物聯網私有雲與環境監測LASS 2018 使用者與開發者大會 物聯網私有雲與環境監測
LASS 2018 使用者與開發者大會 物聯網私有雲與環境監測Tim Hsu
 
[圣思园][Java SE]Network
[圣思园][Java SE]Network[圣思园][Java SE]Network
[圣思园][Java SE]NetworkArBing Xie
 
PhoneGap 通信原理和插件系统
PhoneGap 通信原理和插件系统PhoneGap 通信原理和插件系统
PhoneGap 通信原理和插件系统Tom Fan
 

Similar to Nfc tutorial (15)

Nfc
NfcNfc
Nfc
 
twMVC#09 | RFID 與 NFC 在 Windows8/Windows Phone 8 開發概論
twMVC#09 | RFID 與 NFC 在 Windows8/Windows Phone 8 開發概論twMVC#09 | RFID 與 NFC 在 Windows8/Windows Phone 8 開發概論
twMVC#09 | RFID 與 NFC 在 Windows8/Windows Phone 8 開發概論
 
Android NFC Application Development Environment Setup
Android NFC Application Development Environment SetupAndroid NFC Application Development Environment Setup
Android NFC Application Development Environment Setup
 
Nfc reader writer_mode
Nfc reader writer_modeNfc reader writer_mode
Nfc reader writer_mode
 
组网实践
组网实践组网实践
组网实践
 
IoT感測器驅動程式在樹莓派上實作 IoT Sensor Driver On The Raspberry Pi
IoT感測器驅動程式在樹莓派上實作 IoT Sensor Driver On The Raspberry PiIoT感測器驅動程式在樹莓派上實作 IoT Sensor Driver On The Raspberry Pi
IoT感測器驅動程式在樹莓派上實作 IoT Sensor Driver On The Raspberry Pi
 
智慧家庭 簡報
智慧家庭 簡報智慧家庭 簡報
智慧家庭 簡報
 
IoT感測器驅動程式 在樹莓派上實作
IoT感測器驅動程式在樹莓派上實作IoT感測器驅動程式在樹莓派上實作
IoT感測器驅動程式 在樹莓派上實作
 
04 hou ziqiang
04 hou ziqiang04 hou ziqiang
04 hou ziqiang
 
防火墙产品原理介绍20080407
防火墙产品原理介绍20080407防火墙产品原理介绍20080407
防火墙产品原理介绍20080407
 
05 zhao huiling
05 zhao huiling05 zhao huiling
05 zhao huiling
 
LASS 2018 使用者與開發者大會 物聯網私有雲與環境監測
LASS 2018 使用者與開發者大會 物聯網私有雲與環境監測LASS 2018 使用者與開發者大會 物聯網私有雲與環境監測
LASS 2018 使用者與開發者大會 物聯網私有雲與環境監測
 
Snort分析评估
Snort分析评估Snort分析评估
Snort分析评估
 
[圣思园][Java SE]Network
[圣思园][Java SE]Network[圣思园][Java SE]Network
[圣思园][Java SE]Network
 
PhoneGap 通信原理和插件系统
PhoneGap 通信原理和插件系统PhoneGap 通信原理和插件系统
PhoneGap 通信原理和插件系统
 

More from Roy Chen

The Power of Variable Names
The Power of Variable NamesThe Power of Variable Names
The Power of Variable NamesRoy Chen
 
培養深度工作力
培養深度工作力培養深度工作力
培養深度工作力Roy Chen
 
Svm and libsvm
Svm  and libsvmSvm  and libsvm
Svm and libsvmRoy Chen
 
Phonegap入門
Phonegap入門Phonegap入門
Phonegap入門Roy Chen
 
WiFi direct
WiFi directWiFi direct
WiFi directRoy Chen
 
Cloud service and gae for java(gae:j)
Cloud service and gae for java(gae:j)Cloud service and gae for java(gae:j)
Cloud service and gae for java(gae:j)Roy Chen
 
Processing for fun
Processing for funProcessing for fun
Processing for funRoy Chen
 
聽障朋友科技應用
聽障朋友科技應用聽障朋友科技應用
聽障朋友科技應用Roy Chen
 
Phonegap tricky
Phonegap trickyPhonegap tricky
Phonegap trickyRoy Chen
 

More from Roy Chen (11)

The Power of Variable Names
The Power of Variable NamesThe Power of Variable Names
The Power of Variable Names
 
培養深度工作力
培養深度工作力培養深度工作力
培養深度工作力
 
Svm and libsvm
Svm  and libsvmSvm  and libsvm
Svm and libsvm
 
Phonegap入門
Phonegap入門Phonegap入門
Phonegap入門
 
WiFi direct
WiFi directWiFi direct
WiFi direct
 
Gwt rpc
Gwt rpcGwt rpc
Gwt rpc
 
Cloud service and gae for java(gae:j)
Cloud service and gae for java(gae:j)Cloud service and gae for java(gae:j)
Cloud service and gae for java(gae:j)
 
Processing for fun
Processing for funProcessing for fun
Processing for fun
 
個資法
個資法個資法
個資法
 
聽障朋友科技應用
聽障朋友科技應用聽障朋友科技應用
聽障朋友科技應用
 
Phonegap tricky
Phonegap trickyPhonegap tricky
Phonegap tricky
 

Nfc tutorial

Editor's Notes

  1. 在自己做的APP讀取tag裡面的資訊
  2. Intent-filter會幫你篩選出妳想要接收的tag,因為有可能妳設計的app是專門接收某些資訊;這段code是幫我們篩選出NDEF格式的訊息,資料內容也可做篩選,這裡是只要是文字就可以被我們讀到。 Intent to start an activity when a tag with NDEF payload is discovered.