gtug nfc presentation

23
NFC Programming in Android Ishan Fernando @ifdo [email protected] Myti s.r.l. www.myti.it

Upload: myti-srl

Post on 04-Jul-2015

1.019 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: GTUG NFC Presentation

NFC Programming in Android

Ishan Fernando@ifdo

[email protected]

Myti s.r.l.www.myti.it

Page 2: GTUG NFC Presentation

NFC (Near Field Communication)

E' una tecnologia wireless a corto raggio (< 10cm)

Page 3: GTUG NFC Presentation

NFC (Near Field Communication)

Si opera alla frequenza di 13,56MHzPuò raggiungere una velocità di trasmissione

massima di 424 kbit/s.

Page 4: GTUG NFC Presentation

NFC (Near Field Communication)

E' una evoluzione di RFID (Radio Frequency Identification)

Page 5: GTUG NFC Presentation

Storia

Page 6: GTUG NFC Presentation

NDEF (NFC Data Exchange Format)

NDEF è un formato di incapsulamento dei messaggi (dati) per scambiare informazioni via NFC.

Page 7: GTUG NFC Presentation

NDEF (NFC Data Exchange Format)

Questo formato consente di scambiare informazioni • tra due NFC Forum Devices • tra un NFC Forum Device e un NFC Forum Tag.

Page 8: GTUG NFC Presentation

NDEF (NFC Data Exchange Format)

Message = n * Records

Records = Type +Size +

Payload (binary data)

Page 9: GTUG NFC Presentation

NDEF (NFC Data Exchange Format)

I messaggi NDEF possono essere di tre tipi :

URI il contenuto è un linkMIME il contenuto è specificato da un mime type

NFC-specific types utilizzi specifici per diverse tecnologie

http://www.nfc-forum.org/specs/spec_list/

Page 10: GTUG NFC Presentation

NFC e NDEF summary

NDEF è un formato di encapsulamento dei dati

NFC è una tecnologia wireless a corto raggio che

consente di creare una comunicazione bidirezionale

Page 11: GTUG NFC Presentation

NFC Technology summary

• NFCo Wireless a corto raggio (< 10cm)o Frequenza : 13,56MHz o Velocità di trasmissione massima : 424 Kbit/s.o E' una evoluzione di RFID

• NDEFo Incapsulamento dei messaggio NFC Forum Device <=> NFC Forum Device o NFC Forum Device <=> NFC Forum Tago Message = n * Recordso Records = Type + Size + Payload (binary data)o Types: URI, MIME o NFC-specific types

Page 12: GTUG NFC Presentation

NFC e Android

Page 13: GTUG NFC Presentation

NFC e Android - dispatch system

• Maggior parte delle APIs sono basate su NDEF• The tag dispatch system

Page 14: GTUG NFC Presentation

Intent e Foreground Dispatch Systems

Intent Dispatch Systemdichiara i filtri nel Manifest, fa partire l'applicazione anche se è spenta.

Foreground Dispatch Systemdichiara i filtri mentre in esecuzione, gestione esclusiva per i tag richiesti.

Page 15: GTUG NFC Presentation

Discover NDEF Tag - Permessi

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

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

<uses-feature         android:name="android.hardware.nfc"         android:required="true" />

Page 16: GTUG NFC Presentation

Discover NDEF Tag - Intent filter

<activity>  ...  <intent-filter>

    <action         android:name="android.nfc.action.NDEF_DISCOVERED"/>    <category         android:name="android.intent.category.DEFAULT"/>    <data         android:mimeType="text/plain" />

  </intent-filter>  ...</activity>

Page 17: GTUG NFC Presentation

NDEF Tag - Readingpublic class MyNFCActivity extends Activity { 

  @Override   public void onNewIntent(Intent intent) { 

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

    NdefMessage message = (NdefMessage) raw[0];     NdefRecord record = message.getRecords()[0];     byte[] payload = record.getPayload();     ...

  }

}

Page 18: GTUG NFC Presentation

NDEF Tag - Writingpublic class MyNFCActivity extends Activity {

  @Override  public void onNewIntent(Intent intent) {    Tag t = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);    Ndef ndef = Ndef.get( t );    ndef.connect();    final byte[] data = …;    NdefRecord record = new NdefRecord(            NdefRecord.TNF_MIME_MEDIA,            "text/plain".getBytes(),            new byte[0],            data);    NdefRecord[] records = new NdefRecord[]{record};    NdefMessage message = new NdefMessage( records );        ndef.writeNdefMessage(message);  }}

Page 19: GTUG NFC Presentation

NFC e Android summary

• Dispatch systemso Intent Dispatch Systemo Foreground Dispatch System

• Permessi• Intent Filter• Lettura di un tag NDEF• Scrittura di un tag NDEF

Page 20: GTUG NFC Presentation

Safeatwork

Sicurezza sul lavoro e supporto alla certificazione

Usato dai manutentori e operai specializzatiBackend web per la gestione dei dati

Nata su j2me nel 2008( Nokia 6212 )

www.safeatwork.it

Page 21: GTUG NFC Presentation

Safeatwork

Download contenuti • Schede tecniche• Istruzioni operative

Accesso ai contenuti basato su NFCUpload delle attività• cosa ha fatto l'operatore?• che procedure ha eseguito?

Page 22: GTUG NFC Presentation

SafeatworkL'interazione prevede prevalentemente l'utilizzo della lettura dei tag per accedere ai contenuti.

Page 23: GTUG NFC Presentation

Grazie

Android NFC developer documentationhttp://developer.android.com/guide/topics/nfc/

Nfc Forumhttp://www.nfc-forum.org/home/

Mytiwww.myti.it

Ishan [email protected]@myti.it