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

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 

Recently uploaded (20)

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 

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