Upload
andreas-jakl
View
1.856
Download
1
Tags:
Embed Size (px)
DESCRIPTION
The quick walkthrough will show you how to create your first NFC app for Windows Phone 8. The NearSpeak app (available soon in the WP Store) writes voice NFC tags - touch the tags again to hear your message! Leave notes for your partner, reminders for yourself, or use them for a fun public social experiment. This hands-on tutorial will show you how to create this app. You will see how to write a LaunchApp tag using the NDEF Library for Proximity APIs, how to recognize text spoken by the user, and how to use the speech synthesizer to let the phone read the text again. Note that the instructions require basic knowledge of Windows Phone development.
Citation preview
Windows Phone 8 NFC Quickstart – NearSpeak
1 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
NFC Forum and the NFC Forum logo are trademarks of the Near Field Communication Forum.
Andreas Jakl
[@mopius]
nfcinteractor.com
Technology Wizard
Nokia
2 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
Near Field Communication NearSpeak
3
Near Field Communication
Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
4 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
Scenarios
Connect Devices Exchange Digital Objects Acquire Content
5 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
Pro
xim
ity
AP
Is
Win
do
ws
Ph
on
e 8
+
Win
do
ws
8
Documentation Win8: bit.ly/ProximityAPI
WP8: bit.ly/ProximityAPIwp8
6
NearSpeak
Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
nearspeak.at
7 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
NearSpeak
Record a
voice message Write to an
NFC tag Tap the tag to
launch the app & hear the text!
8 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
General Project Setup 1 Add Capabilities: Proximity, Microphone, Speech Recognition, Networking
Requirement: NFC
2 Initialize ProximityDevice
_device = ProximityDevice.GetDefault();
Connect to HW Detect devices in range Publish & subscribe to messages
_recognizer = new SpeechRecognizer(); _synthesizer = new SpeechSynthesizer();
3 Initialize Speech Recognizer & Synthesizer
9 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
UI Design
10 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
Listen 4 Text recognition (Speech-to-Text)
var recoResult = await _recognizer.RecognizeAsync(); MessageBox.Show(string.Format("You said \"{0}\"\n Please touch a tag to write the message.", recoResult.Text));
11 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
Data on an NFC Tag
Stored on NFC Forum Tag
Encapsulated in NDEF Message
Encoded through NFC Forum
Tag Type Platform
Data NDEF Record(s)
[speech text]
{0450eab3-92…}
Arguments
WindowsPhone app ID
LaunchApp
NDEF = NFC Data Exchange Format, Container image adapted from s_volenszki (Flickr), released under Creative Commons BY-NC 2.0
12 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
NDEF.codeplex.com
Reusable NDEF
classes
Create NDEF messages & records
(standard compliant)
Parse information from raw byte arrays
Fully documented Open Source LGPL license
(based on Qt Mobility)
13 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
Supported Record Types
Smart Poster URI
Text LaunchApp
Android Application Record (AAR) Nokia Accessories Record
Geo tags Social tags SMS tags Telephone call
Why use the library for “Talking Tags”? Creating LaunchApp records is easier, and you can also send them to other phones and not only write to a tag.
14 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
NDEF Library 5 Use NuGet package manager to install NDEF Library for Proximity APIs
15 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
Write NFC Tags 6 Create LaunchApp Message (in button call-back method)
var record = new NdefLaunchAppRecord {Arguments = recoResult.Text}; record.AddPlatformAppId("WindowsPhone", "{...}"); var msg = new NdefMessage {record};
7 Write to the next tag
_device.PublishBinaryMessage("NDEF:WriteTag", msg.ToByteArray().AsBuffer(), MessageWrittenHandler);
16 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
Write NFC Tags 8 NFC message written to a tag? Inform user
private void MessageWrittenHandler( ProximityDevice sender, long messageId) { Dispatcher.BeginInvoke(() => MessageBox.Show( "Message written")); }
17 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
Speak When Launched 9 App launched from a tag? Speak the stored text!
protected override async void OnNavigatedTo( NavigationEventArgs e) { base.OnNavigatedTo(e); if (NavigationContext.QueryString.ContainsKey( "ms_nfp_launchargs")) { await _synthesizer.SpeakTextAsync( NavigationContext.QueryString ["ms_nfp_launchargs"]); } }
18
Nfc Interactor for Windows Phone 8
Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
19 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
nfcinteractor.com
20 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
Near Field Communication NearSpeak
Thank You.
21 Windows Phone 8 NFC Quickstart - NearSpeak v1.1.0 November 20, 2012 © 2012 Andreas Jakl
Andreas Jakl
[@mopius]
nfcinteractor.com
Technology Wizard
Nokia
NFC Introduction bit.ly/NfcIntro Windows (Phone) 8 NFC App Scenarios bit.ly/NFCAppScenarios NFC Development on the Windows 8 Platform bit.ly/Win8NFC NFC Development with Qt on Symbian and MeeGo bit.ly/NfcDevelopment
Re
late
d P
rese
nta
tio
ns