SlideShare a Scribd company logo
1 of 24
A new world is coming…




      @fernando_cejas
    www.fernandocejas.com
Who am I?

• Barcelona GDG Organizer
• NFC, Android and Agile Geek

• Android10.org
• NFC Actions App
• Flojack (@flomio)

• @fernando_cejas
• http://www.fernandocejas.com/
Agenda

•   What is NFC?
•   NFC Features and components
•   Common (and not) use cases
•   Android and NFC
•   Android NFC Development
•   Demo code
•   Faq
What is Near Field Communication?

• Near Field Communication (NFC) is a global standard for
  short-range wireless connectivity technology

• Driven by NFC Forum (http://www.nfc-forum.org) since
  2004.

• 160 + members, including Google, Intel, Microsoft,
  Nokia, NEC, Paypal, At&t, Visa, VTT.

• Promote N-Mark trademark as a universal symbol for
  NFC.
Near Field Communication




 Physical action, virtual reaction

In practice, NFC enables simple and safe
two-way interactions among electronic
devices within a close proximity.
NFC Features
• Short range technology
   – Connection established when devices or tag close enough (5-10
     cm)
   – Simple setup (instant configuration)

• 2-way communication
   – Not only reading like in contactless smart cards, but data exchange

• Passive tags
   – No need for external power
   – Low-price

• Security
  – Support secure element
  – Close proximity use brings some basic security
NFC Modes

• Read and write tags
• Peer-to-peer
• Card emulation

Android support:
  – Read and write (excellent support)
  – P2P (limited)
NFC Tags
How can NFC change the world?
NFC and Android

• Tag Reading: since Android 2.3 – API level 9
• Tag Writing: since Android 2.3.3 – API level 10
• Beam (P2P): Android ICS 4.0 – API level 14

Core Android classes:
  – NFC Manager
  – NFC Adapter
  – Tag Technology classes
NFC Manager




• NFCManager used to get the NFCAdapter
• Boring
• Shortcut for
  getSystemService(NFC_SERVICE)
NFC Adapter

• The real thing

• Control Foreground Dispatch and P2P
  (Android Beam)

• Check if NFC is turned on
Android Manifest

• NFC Permission
<uses-permission android:name="android.permission.NFC" />



• API Level
<uses-sdk android:minSdkVersion="10" />



• NFC Feature
<uses-feature android:name="android.hardware.nfc" android:required="true" />
NDEF Messages
• NFC Data Exchange Format (NDEF)
• NFC Forum Standard
NFC Android Dyspatch System
Android Manifest
In AndroidManifest.xml (4.0+):

<manifest ...>

 <uses-sdk android:minSdkVersion="10" />
 <uses-feature android:name="android.hardware.nfc” android:required="true" />
 <uses-permission android:name="android.permission.NFC" />

 <application ...>
  <activity ...>

   <intent-filter>
    <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="text/plain" /> //Could be custom
   </intent-filter>

  </activity>
 </application>

</manifest>
Activity - Reacting to NFC scans

In the .java file for your Activity:

import android.nfc.NfcAdapter;
import android.nfc.NfcAdapter.CreateNdefMessageCallback;
import android.nfc.NfcEvent;

//...

NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
Boolean nfcEnabled = mNfcAdapter.isEnabled();

//Give priority to the foreground activity to receive NFC scan intents.
mNfcAdapter.enableForegroundDispatch(this, mNfcPendingIntent,
                    mReadTagFilters, null);

//Enable Android Beam for peer-to-peer
 mNfcAdapter.setNdefPushMessageCallback(this,this);
Activity - Formatting to NDEF Format
In the .java file for your Activity:

import android.nfc.NdefMessage;
import android.nfc.NdefRecord;
import android.nfc.tech.Ndef;
import android.nfc.tech.NdefFormatable;
//...

String data = “Hello NFC”;

// create a new NDEF record w/ NDEF message using the app's custom MIME type:
String mimeType = "application/root.gast.playground.nfc"; //unique to your app
byte[] mimeBytes = mimeType.getBytes(Charset.forName("UTF-8"));
byte[] dataBytes = data.getBytes(Charset.forName("UTF-8"));
byte[] id = new byte[0];

NdefRecord record = new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
                                    mimeBytes, id, dataBytes);
NdefMessage m = new NdefMessage(new NdefRecord[] { record });
Activity - Reading NDEF Format

In the .java file for your Activity: import android.nfc.Tag;
//...

Parcelable[] rawMsgs =
 intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES);

NdefMessage[] msgs = new NdefMessage[rawMsgs.length];

for (int i = 0; i < rawMsgs.length; i++) {
  msgs[i] = (NdefMessage) rawMsgs[i];
}

NdefRecord record = msgs[0].getRecords()[0];
byte[] payload = record.getPayload(); //the info you wanted
Activity - Android Beam
In the .java file for your Activity:

//Implement the interface
public class BeamActivity extends Activity implements CreateNdefMessageCallback

// Register callback
mNfcAdapter.setNdefPushMessageCallback(this, this);

public NdefMessage createNdefMessage(NfcEvent event) {
           String data = "Hello NFC”;

     // create a new NDEF record and containing NDEF message:
     String mimeType = "application/com.fernandocejas.example.android.nfc”;
     byte[] mimeBytes = mimeType.getBytes(Charset.forName("UTF-8"));
     byte[] dataBytes = data.getBytes(Charset.forName("UTF-8"));
     byte[] id = new byte[0];
     NdefRecord record = new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
                              mimeBytes, id, dataBytes);
     NdefMessage message = new NdefMessage(new NdefRecord[] { record });

     return message;
}
Sample Application




      https://github.com/android10
Mobile OS support for NFC
Any questions?
Thanks!




When you look at the dark side, careful you
 must be ... for the dark side looks back.

             @fernando_cejas
           www.fernandocejas.com

More Related Content

Viewers also liked

Neuro science and mystical experience
Neuro science and mystical experienceNeuro science and mystical experience
Neuro science and mystical experienceJoby Mathew
 
Bahaya narkoba kesehatan
Bahaya narkoba kesehatanBahaya narkoba kesehatan
Bahaya narkoba kesehatanRudy Irawan
 
Penyuluhan tentang bahaya penyalahgunaan narkotika
Penyuluhan tentang bahaya penyalahgunaan narkotikaPenyuluhan tentang bahaya penyalahgunaan narkotika
Penyuluhan tentang bahaya penyalahgunaan narkotikaArif Kurniawan
 
Bluetooth Secure Simple Pairing Using NFC Part 2
Bluetooth Secure Simple Pairing Using NFC Part 2Bluetooth Secure Simple Pairing Using NFC Part 2
Bluetooth Secure Simple Pairing Using NFC Part 2NFC Forum
 
presentasi keren bahaya narkoba
presentasi keren bahaya narkobapresentasi keren bahaya narkoba
presentasi keren bahaya narkobatelnong
 
presentasi penyalahgunaan narkoba
 presentasi penyalahgunaan narkoba presentasi penyalahgunaan narkoba
presentasi penyalahgunaan narkobaRinaldi Asertua
 
Contoh Presentasi Power Point Tentang Pendidikan
Contoh Presentasi Power Point Tentang PendidikanContoh Presentasi Power Point Tentang Pendidikan
Contoh Presentasi Power Point Tentang PendidikanMustofa Thovids
 
NFC Technology
NFC TechnologyNFC Technology
NFC TechnologyNeha Singh
 
Near field communication (nfc) technology
Near field communication (nfc) technologyNear field communication (nfc) technology
Near field communication (nfc) technologyAnkur Sharma
 
NEAR FIELD COMMUNICATION
NEAR FIELD COMMUNICATIONNEAR FIELD COMMUNICATION
NEAR FIELD COMMUNICATIONHarisankar U K
 
NFC & RFID on Android
NFC & RFID on AndroidNFC & RFID on Android
NFC & RFID on Androidtodbotdotcom
 

Viewers also liked (16)

Neuro science and mystical experience
Neuro science and mystical experienceNeuro science and mystical experience
Neuro science and mystical experience
 
Narkoba
NarkobaNarkoba
Narkoba
 
Bahaya narkoba kesehatan
Bahaya narkoba kesehatanBahaya narkoba kesehatan
Bahaya narkoba kesehatan
 
Penyuluhan tentang bahaya penyalahgunaan narkotika
Penyuluhan tentang bahaya penyalahgunaan narkotikaPenyuluhan tentang bahaya penyalahgunaan narkotika
Penyuluhan tentang bahaya penyalahgunaan narkotika
 
Persentasi narkoba
Persentasi narkobaPersentasi narkoba
Persentasi narkoba
 
NARKOBA
NARKOBANARKOBA
NARKOBA
 
Bluetooth Secure Simple Pairing Using NFC Part 2
Bluetooth Secure Simple Pairing Using NFC Part 2Bluetooth Secure Simple Pairing Using NFC Part 2
Bluetooth Secure Simple Pairing Using NFC Part 2
 
NFC In Mobile Commerce
NFC In Mobile CommerceNFC In Mobile Commerce
NFC In Mobile Commerce
 
presentasi keren bahaya narkoba
presentasi keren bahaya narkobapresentasi keren bahaya narkoba
presentasi keren bahaya narkoba
 
presentasi penyalahgunaan narkoba
 presentasi penyalahgunaan narkoba presentasi penyalahgunaan narkoba
presentasi penyalahgunaan narkoba
 
Contoh Presentasi Power Point Tentang Pendidikan
Contoh Presentasi Power Point Tentang PendidikanContoh Presentasi Power Point Tentang Pendidikan
Contoh Presentasi Power Point Tentang Pendidikan
 
Nfc ppt
Nfc pptNfc ppt
Nfc ppt
 
NFC Technology
NFC TechnologyNFC Technology
NFC Technology
 
Near field communication (nfc) technology
Near field communication (nfc) technologyNear field communication (nfc) technology
Near field communication (nfc) technology
 
NEAR FIELD COMMUNICATION
NEAR FIELD COMMUNICATIONNEAR FIELD COMMUNICATION
NEAR FIELD COMMUNICATION
 
NFC & RFID on Android
NFC & RFID on AndroidNFC & RFID on Android
NFC & RFID on Android
 

Similar to Nfc on Android

NFC Bootcamp Seattle Day 2
NFC Bootcamp Seattle Day 2 NFC Bootcamp Seattle Day 2
NFC Bootcamp Seattle Day 2 traceebeebe
 
Wireless sensor networks using android virtual devices and near field
Wireless sensor networks using android virtual devices and near fieldWireless sensor networks using android virtual devices and near field
Wireless sensor networks using android virtual devices and near fieldNicolas Kockel
 
NFC on Android - Near Field Communication
NFC on Android - Near Field CommunicationNFC on Android - Near Field Communication
NFC on Android - Near Field CommunicationSven Haiges
 
Windows 8 Platform NFC Development
Windows 8 Platform NFC DevelopmentWindows 8 Platform NFC Development
Windows 8 Platform NFC DevelopmentAndreas Jakl
 
Android Basic Presentation (Introduction)
Android Basic Presentation (Introduction)Android Basic Presentation (Introduction)
Android Basic Presentation (Introduction)RAHUL TRIPATHI
 
ABC2011Winter デ部 NFC
ABC2011Winter デ部 NFCABC2011Winter デ部 NFC
ABC2011Winter デ部 NFCMasahiro Wakame
 
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
 
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
 
NFiD: An NFC based system for Digital Business Cards
NFiD: An NFC based system for Digital Business CardsNFiD: An NFC based system for Digital Business Cards
NFiD: An NFC based system for Digital Business CardsIRJET Journal
 
Near field communication (NFC) in android
Near field communication (NFC) in androidNear field communication (NFC) in android
Near field communication (NFC) in androidMindfire Solutions
 
How to Install and Use Kubernetes by Weaveworks
How to Install and Use Kubernetes by Weaveworks How to Install and Use Kubernetes by Weaveworks
How to Install and Use Kubernetes by Weaveworks Weaveworks
 
Orchestrating Microservices with Kubernetes
Orchestrating Microservices with Kubernetes Orchestrating Microservices with Kubernetes
Orchestrating Microservices with Kubernetes Weaveworks
 
Nfc sfdc mobile_sdk
Nfc sfdc mobile_sdkNfc sfdc mobile_sdk
Nfc sfdc mobile_sdkCory Cowgill
 
How to install and use Kubernetes
How to install and use KubernetesHow to install and use Kubernetes
How to install and use KubernetesLuke Marsden
 

Similar to Nfc on Android (20)

NFC Bootcamp Seattle Day 2
NFC Bootcamp Seattle Day 2 NFC Bootcamp Seattle Day 2
NFC Bootcamp Seattle Day 2
 
Android NFC
Android NFCAndroid NFC
Android NFC
 
Wireless sensor networks using android virtual devices and near field
Wireless sensor networks using android virtual devices and near fieldWireless sensor networks using android virtual devices and near field
Wireless sensor networks using android virtual devices and near field
 
NFC on Android - Near Field Communication
NFC on Android - Near Field CommunicationNFC on Android - Near Field Communication
NFC on Android - Near Field Communication
 
Windows 8 Platform NFC Development
Windows 8 Platform NFC DevelopmentWindows 8 Platform NFC Development
Windows 8 Platform NFC Development
 
02 dev room6__tapand_go_jeffprosise_9Tap and Go: Proximity Networking in WinRT
02 dev room6__tapand_go_jeffprosise_9Tap and Go: Proximity Networking in WinRT02 dev room6__tapand_go_jeffprosise_9Tap and Go: Proximity Networking in WinRT
02 dev room6__tapand_go_jeffprosise_9Tap and Go: Proximity Networking in WinRT
 
Android Basic Presentation (Introduction)
Android Basic Presentation (Introduction)Android Basic Presentation (Introduction)
Android Basic Presentation (Introduction)
 
ABC2011Winter デ部 NFC
ABC2011Winter デ部 NFCABC2011Winter デ部 NFC
ABC2011Winter デ部 NFC
 
Getting Native with NDK
Getting Native with NDKGetting Native with NDK
Getting Native with NDK
 
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)
 
Developing NFC Apps
Developing NFC AppsDeveloping NFC Apps
Developing NFC Apps
 
Air superiority for Android Apps
Air superiority for Android AppsAir superiority for Android Apps
Air superiority for Android Apps
 
NFC (Windows 8/ Windows Phone 8 )
NFC (Windows 8/ Windows Phone 8 )NFC (Windows 8/ Windows Phone 8 )
NFC (Windows 8/ Windows Phone 8 )
 
NFiD: An NFC based system for Digital Business Cards
NFiD: An NFC based system for Digital Business CardsNFiD: An NFC based system for Digital Business Cards
NFiD: An NFC based system for Digital Business Cards
 
Near field communication (NFC) in android
Near field communication (NFC) in androidNear field communication (NFC) in android
Near field communication (NFC) in android
 
How to Install and Use Kubernetes by Weaveworks
How to Install and Use Kubernetes by Weaveworks How to Install and Use Kubernetes by Weaveworks
How to Install and Use Kubernetes by Weaveworks
 
Orchestrating Microservices with Kubernetes
Orchestrating Microservices with Kubernetes Orchestrating Microservices with Kubernetes
Orchestrating Microservices with Kubernetes
 
Nfc sfdc mobile_sdk
Nfc sfdc mobile_sdkNfc sfdc mobile_sdk
Nfc sfdc mobile_sdk
 
NFC and the Salesforce Mobile SDK
NFC and the Salesforce Mobile SDKNFC and the Salesforce Mobile SDK
NFC and the Salesforce Mobile SDK
 
How to install and use Kubernetes
How to install and use KubernetesHow to install and use Kubernetes
How to install and use Kubernetes
 

More from Fernando Cejas

The Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on AndroidThe Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on AndroidFernando Cejas
 
It is about philosophy: culture of a good programmer
It is about philosophy: culture of a good programmerIt is about philosophy: culture of a good programmer
It is about philosophy: culture of a good programmerFernando Cejas
 
Material Design for Old Schoolers
Material Design for Old SchoolersMaterial Design for Old Schoolers
Material Design for Old SchoolersFernando Cejas
 
How to Become the MacGyver of Android Custom Views
How to Become the MacGyver of Android Custom ViewsHow to Become the MacGyver of Android Custom Views
How to Become the MacGyver of Android Custom ViewsFernando Cejas
 
Android UX-UI Design for Fun and Profit
Android UX-UI Design for Fun and ProfitAndroid UX-UI Design for Fun and Profit
Android UX-UI Design for Fun and ProfitFernando Cejas
 
How ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionHow ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionFernando Cejas
 
How ANDROID TESTING changed how we think about Death
How ANDROID TESTING changed how we think about DeathHow ANDROID TESTING changed how we think about Death
How ANDROID TESTING changed how we think about DeathFernando Cejas
 
Dinosaurs and Androids: The Listview Evolution
Dinosaurs and Androids: The Listview EvolutionDinosaurs and Androids: The Listview Evolution
Dinosaurs and Androids: The Listview EvolutionFernando Cejas
 
Inside Android Testing
Inside Android TestingInside Android Testing
Inside Android TestingFernando Cejas
 
Webview: The fifth element
Webview: The fifth elementWebview: The fifth element
Webview: The fifth elementFernando Cejas
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design PatternsFernando Cejas
 
Android Cloud To Device Messaging
Android Cloud To Device MessagingAndroid Cloud To Device Messaging
Android Cloud To Device MessagingFernando Cejas
 
Android Quick Introduction
Android Quick IntroductionAndroid Quick Introduction
Android Quick IntroductionFernando Cejas
 
Desarrollo android almacenamiento de datos
Desarrollo android    almacenamiento de datosDesarrollo android    almacenamiento de datos
Desarrollo android almacenamiento de datosFernando Cejas
 
Android simple 2d Layout animation
Android simple 2d Layout animationAndroid simple 2d Layout animation
Android simple 2d Layout animationFernando Cejas
 

More from Fernando Cejas (15)

The Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on AndroidThe Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on Android
 
It is about philosophy: culture of a good programmer
It is about philosophy: culture of a good programmerIt is about philosophy: culture of a good programmer
It is about philosophy: culture of a good programmer
 
Material Design for Old Schoolers
Material Design for Old SchoolersMaterial Design for Old Schoolers
Material Design for Old Schoolers
 
How to Become the MacGyver of Android Custom Views
How to Become the MacGyver of Android Custom ViewsHow to Become the MacGyver of Android Custom Views
How to Become the MacGyver of Android Custom Views
 
Android UX-UI Design for Fun and Profit
Android UX-UI Design for Fun and ProfitAndroid UX-UI Design for Fun and Profit
Android UX-UI Design for Fun and Profit
 
How ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionHow ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second Edition
 
How ANDROID TESTING changed how we think about Death
How ANDROID TESTING changed how we think about DeathHow ANDROID TESTING changed how we think about Death
How ANDROID TESTING changed how we think about Death
 
Dinosaurs and Androids: The Listview Evolution
Dinosaurs and Androids: The Listview EvolutionDinosaurs and Androids: The Listview Evolution
Dinosaurs and Androids: The Listview Evolution
 
Inside Android Testing
Inside Android TestingInside Android Testing
Inside Android Testing
 
Webview: The fifth element
Webview: The fifth elementWebview: The fifth element
Webview: The fifth element
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design Patterns
 
Android Cloud To Device Messaging
Android Cloud To Device MessagingAndroid Cloud To Device Messaging
Android Cloud To Device Messaging
 
Android Quick Introduction
Android Quick IntroductionAndroid Quick Introduction
Android Quick Introduction
 
Desarrollo android almacenamiento de datos
Desarrollo android    almacenamiento de datosDesarrollo android    almacenamiento de datos
Desarrollo android almacenamiento de datos
 
Android simple 2d Layout animation
Android simple 2d Layout animationAndroid simple 2d Layout animation
Android simple 2d Layout animation
 

Recently uploaded

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
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
 
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
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
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
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Nfc on Android

  • 1. A new world is coming… @fernando_cejas www.fernandocejas.com
  • 2. Who am I? • Barcelona GDG Organizer • NFC, Android and Agile Geek • Android10.org • NFC Actions App • Flojack (@flomio) • @fernando_cejas • http://www.fernandocejas.com/
  • 3. Agenda • What is NFC? • NFC Features and components • Common (and not) use cases • Android and NFC • Android NFC Development • Demo code • Faq
  • 4. What is Near Field Communication? • Near Field Communication (NFC) is a global standard for short-range wireless connectivity technology • Driven by NFC Forum (http://www.nfc-forum.org) since 2004. • 160 + members, including Google, Intel, Microsoft, Nokia, NEC, Paypal, At&t, Visa, VTT. • Promote N-Mark trademark as a universal symbol for NFC.
  • 5. Near Field Communication Physical action, virtual reaction In practice, NFC enables simple and safe two-way interactions among electronic devices within a close proximity.
  • 6. NFC Features • Short range technology – Connection established when devices or tag close enough (5-10 cm) – Simple setup (instant configuration) • 2-way communication – Not only reading like in contactless smart cards, but data exchange • Passive tags – No need for external power – Low-price • Security – Support secure element – Close proximity use brings some basic security
  • 7. NFC Modes • Read and write tags • Peer-to-peer • Card emulation Android support: – Read and write (excellent support) – P2P (limited)
  • 9. How can NFC change the world?
  • 10. NFC and Android • Tag Reading: since Android 2.3 – API level 9 • Tag Writing: since Android 2.3.3 – API level 10 • Beam (P2P): Android ICS 4.0 – API level 14 Core Android classes: – NFC Manager – NFC Adapter – Tag Technology classes
  • 11. NFC Manager • NFCManager used to get the NFCAdapter • Boring • Shortcut for getSystemService(NFC_SERVICE)
  • 12. NFC Adapter • The real thing • Control Foreground Dispatch and P2P (Android Beam) • Check if NFC is turned on
  • 13. Android Manifest • NFC Permission <uses-permission android:name="android.permission.NFC" /> • API Level <uses-sdk android:minSdkVersion="10" /> • NFC Feature <uses-feature android:name="android.hardware.nfc" android:required="true" />
  • 14. NDEF Messages • NFC Data Exchange Format (NDEF) • NFC Forum Standard
  • 16. Android Manifest In AndroidManifest.xml (4.0+): <manifest ...> <uses-sdk android:minSdkVersion="10" /> <uses-feature android:name="android.hardware.nfc” android:required="true" /> <uses-permission android:name="android.permission.NFC" /> <application ...> <activity ...> <intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED"/> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> //Could be custom </intent-filter> </activity> </application> </manifest>
  • 17. Activity - Reacting to NFC scans In the .java file for your Activity: import android.nfc.NfcAdapter; import android.nfc.NfcAdapter.CreateNdefMessageCallback; import android.nfc.NfcEvent; //... NfcAdapter mNfcAdapter = NfcAdapter.getDefaultAdapter(this); Boolean nfcEnabled = mNfcAdapter.isEnabled(); //Give priority to the foreground activity to receive NFC scan intents. mNfcAdapter.enableForegroundDispatch(this, mNfcPendingIntent, mReadTagFilters, null); //Enable Android Beam for peer-to-peer mNfcAdapter.setNdefPushMessageCallback(this,this);
  • 18. Activity - Formatting to NDEF Format In the .java file for your Activity: import android.nfc.NdefMessage; import android.nfc.NdefRecord; import android.nfc.tech.Ndef; import android.nfc.tech.NdefFormatable; //... String data = “Hello NFC”; // create a new NDEF record w/ NDEF message using the app's custom MIME type: String mimeType = "application/root.gast.playground.nfc"; //unique to your app byte[] mimeBytes = mimeType.getBytes(Charset.forName("UTF-8")); byte[] dataBytes = data.getBytes(Charset.forName("UTF-8")); byte[] id = new byte[0]; NdefRecord record = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeBytes, id, dataBytes); NdefMessage m = new NdefMessage(new NdefRecord[] { record });
  • 19. Activity - Reading NDEF Format In the .java file for your Activity: import android.nfc.Tag; //... Parcelable[] rawMsgs = intent.getParcelableArrayExtra(NfcAdapter.EXTRA_NDEF_MESSAGES); NdefMessage[] msgs = new NdefMessage[rawMsgs.length]; for (int i = 0; i < rawMsgs.length; i++) { msgs[i] = (NdefMessage) rawMsgs[i]; } NdefRecord record = msgs[0].getRecords()[0]; byte[] payload = record.getPayload(); //the info you wanted
  • 20. Activity - Android Beam In the .java file for your Activity: //Implement the interface public class BeamActivity extends Activity implements CreateNdefMessageCallback // Register callback mNfcAdapter.setNdefPushMessageCallback(this, this); public NdefMessage createNdefMessage(NfcEvent event) { String data = "Hello NFC”; // create a new NDEF record and containing NDEF message: String mimeType = "application/com.fernandocejas.example.android.nfc”; byte[] mimeBytes = mimeType.getBytes(Charset.forName("UTF-8")); byte[] dataBytes = data.getBytes(Charset.forName("UTF-8")); byte[] id = new byte[0]; NdefRecord record = new NdefRecord(NdefRecord.TNF_MIME_MEDIA, mimeBytes, id, dataBytes); NdefMessage message = new NdefMessage(new NdefRecord[] { record }); return message; }
  • 21. Sample Application https://github.com/android10
  • 22. Mobile OS support for NFC
  • 24. Thanks! When you look at the dark side, careful you must be ... for the dark side looks back. @fernando_cejas www.fernandocejas.com