跳到主要內容

發表文章

目前顯示的是有「background service」標籤的文章

[UWP] Display a map on Cortana Canvas through UWP voice command

This article focuses on how to get map info from bingmap service and response to Cortana via UWP Voice Command. Subscribe Azure Bing Map Service Create Bing Map Api on Azure portal. Save your QueryKey, you have to use this key to get map info later. Voice Command Background app service Create a helper class for bingmap service: Since Cortana only accept text and local image file responds from our UWP,  we have to store the online map information as a local file and pass to Cortana. Response VoiceCommandContentTile to Cortana

[UWP] 背景處理Cortana 的Voice Command 請求

前言 如果你希望開發一支UWP在背景處理事情, 然後將處理完的資料或狀態顯示在Cortana的Canvas上面的話, 我們會需要寫一個backgound server去處理Cortana的請求, 而基本上有以下幾個步驟 Step 1. 前置步驟 新增專案 選擇Windows Runtime Component 專案建立好之後, 我們先把Class1.cs重新命名(列如 MyVoiceCommandService.cs) 設定Package.appxmanifest 加入以下的程式碼, 然後把EntryPoint指定到剛剛建立的MyVoiceCommandService.cs 編輯VoiceCommand.xml 實作IBackgroundTask Step 2. 處理Cortana VoiceCommand的請求 取得VoiceCommandServiceConnection實體 這是用來讓我們的背景程式與Cortana溝通的介面 建立Response的內容 基本上我們可以回傳VoiceCommandUserMessage, VoiceCommandContentTile這兩種內容給Cortana User Messag 讓Cortana說話, 或是讓她秀訊息在Canvas上面 Content Tile 這個有點像是Bot Framework中的Card, 我們可以把文字跟圖片塞在Content Tile中讓Canvas顯示出來, 我們可以一次回傳多個Content Tile, 當使用者點了其中一個之後, 就會觸發開啟我們程式的事件 VoiceCommandResponse 建立VoiceCommandResponse的實體, 然後塞入剛剛建立的VoiceCommandUserMessage 或是 VoiceCommandContentTile, 最後再透過VoiceCommandServiceConnection回傳給Cortana Demo Hey Cortana, find God Father on My Library 完整程式碼 https://github.com/andy51002000/Simple-UWP...