Windows Phone 8 SensorsDavid IsbitskiTechnical Evangelist, Microsofthttp://blogs.msdn.com/davedev@TheDaveDev
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Geolocator geolocator = new Geolocator();geolocator.DesiredAccuracyInMeters = 50;Geoposition myLocation = awaitgeolocator....
void newPosition(Geolocator sender, PositionChangedEventArgs args){    Deployment.Current.Dispatcher.BeginInvoke(() =>    ...
<Grid x:Name="ContentPanel" >      <maps:Map x:Name="MyMap"/></Grid>private void CreateMap() {     Map MyMap = new Map(); ...
MapDownloaderTask mdt = new MapDownloaderTask();mdt.Show();
ProximityDevice device = ProximityDevice.GetDefault();// Make sure NFC is supportedif (device != null){    _device.DeviceA...
void device_DeviceArrived(ProximityDevice sender){    if (sendingString)    {        sender.PublishMessage("MyStringMessag...
private void StringMessageHandler(ProximityDevicesender, ProximityMessage message){    string messageRecieved = message.Da...
private void ByteMessageHandler(ProximityDevice sender, ProximityMessagemessage){    byte[] messageBytes;    using (DataRe...
ProximityDevice device = ProximityDevice.GetDefault();// Make sure NFC is supportedif (device != null){    PeerFinder.Trig...
void OnTriggeredConnectionStateChanged(object sender,                                       TriggeredConnectionStateChange...
PeerFinder.AllowBluetooth = true;PeerFinder.AllowInfrastructure = true;
async void CheeseLiker(){    SpeechSynthesizer synth = new SpeechSynthesizer();    await synth.SpeakTextAsync("I like chee...
foreach (VoiceInformation vi in InstalledVoices.All){    if (vi.Language == "de-DE")    {        _speechSynth = new Speech...
SpeechRecognizerUI recoWithUI;async private void ListenButton_Click(object sender, RoutedEventArgs e){    this.recoWithUI ...
foreach(SpeechRecognizerInformation sri        in InstalledSpeechRecognizers.All){    if(sri.Language == "de-DE")        _...
Windows Phone 8Sensors: Speech APIs
<CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney">  <Example>...
<CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney">  <Example>...
<CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney">  <Example>...
<CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney">  <Example>...
<CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney">  <Example>...
<CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney">  <Example>...
<CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney">  <Example>...
<CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney">  <Example>...
<CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney">  <Example>...
/Money.xaml/?voiceCommandName=showMoney&futureMoney=gold&reco=Fortune%20Teller%Will%20I%20find%20gold"
Windows Phone 8 SensorsDavid IsbitskiTechnical Evangelist, Microsofthttp://blogs.msdn.com/davedev@TheDaveDev
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Windows Phone 8 Sensors
Upcoming SlideShare
Loading in...5
×

Windows Phone 8 Sensors

355

Published on

Session:
4 - Windows Phone 8 Sensors

Event:
Washington DC Windows Phone 8 Jumpstart

Date:
March 2013

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
355
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Windows Phone 8 Sensors

  1. 1. Windows Phone 8 SensorsDavid IsbitskiTechnical Evangelist, Microsofthttp://blogs.msdn.com/davedev@TheDaveDev
  2. 2. Windows Phone 8 Sensors
  3. 3. Windows Phone 8 Sensors
  4. 4. Geolocator geolocator = new Geolocator();geolocator.DesiredAccuracyInMeters = 50;Geoposition myLocation = awaitgeolocator.GetGeopositionAsync(maximumAge, timeout);// We need to convert the Geoposition to a GeoCoordinate to show it on the mapGeoCoordinate geoCord = newGeoCoordinate(myLocation.Coordinate.Latitude, myLocation.Coordinate.Longitude);MyMapControl.Center = geoCord;// Set up an event handler to watch for location updatesgeolocator.PositionChanged += updatePosition;
  5. 5. void newPosition(Geolocator sender, PositionChangedEventArgs args){ Deployment.Current.Dispatcher.BeginInvoke(() => { GeoCoordinate geoCord = new GeoCoordinate(args.Position.Coordinate.Latitude, args.Position.Coordinate.Longitude); MyMapControl.Center = geoCord; });}
  6. 6. <Grid x:Name="ContentPanel" > <maps:Map x:Name="MyMap"/></Grid>private void CreateMap() { Map MyMap = new Map(); ContentPanel.Children.Add(MyMap); }
  7. 7. MapDownloaderTask mdt = new MapDownloaderTask();mdt.Show();
  8. 8. ProximityDevice device = ProximityDevice.GetDefault();// Make sure NFC is supportedif (device != null){ _device.DeviceArrived += device_DeviceArrived; _device.SubscribeForMessage(“StringMessage", StringMessageHandler); _device.SubscribeForMessage(“ByteMessage", ByteMessageHandler); PeerFinder.Start();}
  9. 9. void device_DeviceArrived(ProximityDevice sender){ if (sendingString) { sender.PublishMessage("MyStringMessage", someString); } else if (sendingBytes) { var messageWriter = new DataWriter(); messageWriter.UnicodeEncoding = UnicodeEncoding.Utf16LE; messageWriter.WriteBytes(someBytes); sender.PublishBinaryMessage("MyBinaryMessage", messageWriter.DetachBuffer()); }}
  10. 10. private void StringMessageHandler(ProximityDevicesender, ProximityMessage message){ string messageRecieved = message.DataAsString;}
  11. 11. private void ByteMessageHandler(ProximityDevice sender, ProximityMessagemessage){ byte[] messageBytes; using (DataReader dReader = DataReader.FromBuffer(message.Data)) { messageBytes = new byte[dReader.UnconsumedBufferLength]; dReader.ReadBytes(messageBytes); }}
  12. 12. ProximityDevice device = ProximityDevice.GetDefault();// Make sure NFC is supportedif (device != null){ PeerFinder.TriggeredConnectionStateChanged +=OnTriggeredConnectionStateChanged; // Start finding peer apps, while making app discoverable by peers PeerFinder.Start();}
  13. 13. void OnTriggeredConnectionStateChanged(object sender, TriggeredConnectionStateChangedEventArgs args) { switch (args.State) { case TriggeredConnectState.Listening: // Connecting as host break; case TriggeredConnectState.PeerFound: // Proximity gesture is complete – setting up link break; case TriggeredConnectState.Connecting: // Connecting as a client break; case TriggeredConnectState.Completed: // Connection completed, get the socket streamSocket = args.Socket; break; case TriggeredConnectState.Canceled: // ongoing connection canceled break; case TriggeredConnectState.Failed: // Connection was unsuccessful break; }}
  14. 14. PeerFinder.AllowBluetooth = true;PeerFinder.AllowInfrastructure = true;
  15. 15. async void CheeseLiker(){ SpeechSynthesizer synth = new SpeechSynthesizer(); await synth.SpeakTextAsync("I like cheese.");}
  16. 16. foreach (VoiceInformation vi in InstalledVoices.All){ if (vi.Language == "de-DE") { _speechSynth = new SpeechSynthesizer(); _speechSynth.SetVoice(vi); }}
  17. 17. SpeechRecognizerUI recoWithUI;async private void ListenButton_Click(object sender, RoutedEventArgs e){ this.recoWithUI = new SpeechRecognizerUI(); SpeechRecognitionUIResult recoResult = await recoWithUI.RecognizeWithUIAsync(); if ( recoResult.ResultStatus == SpeechRecognitionUIStatus.Succeeded ) MessageBox.Show(string.Format("You said {0}.", recoResult.RecognitionResult.Text));}
  18. 18. foreach(SpeechRecognizerInformation sri in InstalledSpeechRecognizers.All){ if(sri.Language == "de-DE") _speechRecognizer.Recognizer.SetRecognizer(sri);}
  19. 19. Windows Phone 8Sensors: Speech APIs
  20. 20. <CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney"> <Example> Will I find money </Example> <ListenFor> [Will I find] {futureMoney} </ListenFor> <Feedback> Showing {futureMoney} </Feedback> <Navigate Target="/money.xaml"/></Command><PhraseList Label="futureMoney"> <Item> money </Item> <Item> riches </Item> <Item> gold </Item></PhraseList>
  21. 21. <CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney"> <Example> Will I find money </Example> <ListenFor> [Will I find] {futureMoney} </ListenFor> <Feedback> Showing {futureMoney} </Feedback> <Navigate Target="/money.xaml"/></Command><PhraseList Label="futureMoney"> <Item> money </Item> <Item> riches </Item> <Item> gold </Item></PhraseList>
  22. 22. <CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney"> <Example> Will I find money </Example> <ListenFor> [Will I find] {futureMoney} </ListenFor> <Feedback> Showing {futureMoney} </Feedback> <Navigate Target="/money.xaml"/></Command><PhraseList Label="futureMoney"> <Item> money </Item> <Item> riches </Item> <Item> gold </Item></PhraseList>
  23. 23. <CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney"> <Example> Will I find money </Example> <ListenFor> [Will I find] {futureMoney} </ListenFor> <Feedback> Showing {futureMoney} </Feedback> <Navigate Target="/money.xaml"/></Command><PhraseList Label="futureMoney"> <Item> money </Item> <Item> riches </Item> <Item> gold </Item></PhraseList>
  24. 24. <CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney"> <Example> Will I find money </Example> <ListenFor> [Will I find] {futureMoney} </ListenFor> <Feedback> Showing {futureMoney} </Feedback> <Navigate Target="/money.xaml"/></Command><PhraseList Label="futureMoney"> <Item> money </Item> <Item> riches </Item> <Item> gold </Item></PhraseList>
  25. 25. <CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney"> <Example> Will I find money </Example> <ListenFor> [Will I find] {futureMoney} </ListenFor> <Feedback> Showing {futureMoney} </Feedback> <Navigate Target="/money.xaml"/></Command><PhraseList Label="futureMoney"> <Item> money </Item> <Item> riches </Item> <Item> gold </Item></PhraseList>
  26. 26. <CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney"> <Example> Will I find money </Example> <ListenFor> [Will I find] {futureMoney} </ListenFor> <Feedback> Showing {futureMoney} </Feedback> <Navigate Target="/money.xaml"/></Command><PhraseList Label="futureMoney"> <Item> money </Item> <Item> riches </Item> <Item> gold </Item></PhraseList>
  27. 27. <CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney"> <Example> Will I find money </Example> <ListenFor> [Will I find] {futureMoney} </ListenFor> <Feedback> Showing {futureMoney} </Feedback> <Navigate Target="/money.xaml"/></Command><PhraseList Label="futureMoney"> <Item> money </Item> <Item> riches </Item> <Item> gold </Item></PhraseList>
  28. 28. <CommandPrefix> Fortune Teller </CommandPrefix><Example> Will I find money </Example><Command Name="showMoney"> <Example> Will I find money </Example> <ListenFor> [Will I find] {futureMoney} </ListenFor> <Feedback> Showing {futureMoney} </Feedback> <Navigate Target="/money.xaml"/></Command><PhraseList Label="futureMoney"> <Item> money </Item> <Item> riches </Item> <Item> gold </Item></PhraseList>
  29. 29. /Money.xaml/?voiceCommandName=showMoney&futureMoney=gold&reco=Fortune%20Teller%Will%20I%20find%20gold"
  30. 30. Windows Phone 8 SensorsDavid IsbitskiTechnical Evangelist, Microsofthttp://blogs.msdn.com/davedev@TheDaveDev
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×