@@ -11,8 +11,6 @@ keywords: cortana
11
11
12
12
> [ !WARNING]
13
13
> This feature is no longer supported as of the Windows 10 May 2020 Update (version 2004, codename "20H1").
14
- >
15
- > See [ Cortana in Microsoft 365] ( /microsoft-365/admin/misc/cortana-integration ) for how Cortana is transforming modern productivity experiences.
16
14
17
15
Provide deep links from a background app in ** Cortana** that launch the app to the foreground in a specific state or context.
18
16
@@ -72,19 +70,19 @@ Finally, we call the [**ReportSuccessAsync**](/uwp/api/Windows.ApplicationModel.
72
70
private async Task SendCompletionMessageForDestination (string destination )
73
71
{
74
72
.. .
75
- IEnumerable < Model .Trip > trips = store .Trips .Where (p => p .Destination == destination );
73
+ IEnumerable < Model .Trip > trips = store .Trips .Where (p => p .Destination == destination );
76
74
77
- var userMessage = new VoiceCommandUserMessage ();
78
- var destinationsContentTiles = new List <VoiceCommandContentTile >();
75
+ var userMessage = new VoiceCommandUserMessage ();
76
+ var destinationsContentTiles = new List <VoiceCommandContentTile >();
79
77
.. .
80
- var response = VoiceCommandResponse .CreateResponse (userMessage , destinationsContentTiles );
78
+ var response = VoiceCommandResponse .CreateResponse (userMessage , destinationsContentTiles );
81
79
82
- if (trips .Count () > 0 )
83
- {
84
- response .AppLaunchArgument = destination ;
85
- }
80
+ if (trips .Count () > 0 )
81
+ {
82
+ response .AppLaunchArgument = destination ;
83
+ }
86
84
87
- await voiceServiceConnection .ReportSuccessAsync (response );
85
+ await voiceServiceConnection .ReportSuccessAsync (response );
88
86
}
89
87
```
90
88
@@ -113,80 +111,80 @@ Here, we add two content tiles with different [**AppLaunchArgument**](/uwp/api/W
113
111
/// <param name =" destination" >The destination specified in the voice command.</param >
114
112
private async Task SendCompletionMessageForDestination (string destination )
115
113
{
116
- // If this operation is expected to take longer than 0.5 seconds, the task must
117
- // supply a progress response to Cortana before starting the operation, and
118
- // updates must be provided at least every 5 seconds.
119
- string loadingTripToDestination = string .Format (
120
- cortanaResourceMap .GetValue (" LoadingTripToDestination" , cortanaContext ).ValueAsString ,
121
- destination );
122
- await ShowProgressScreen (loadingTripToDestination );
123
- Model .TripStore store = new Model .TripStore ();
124
- await store .LoadTrips ();
125
-
126
- // Query for the specified trip.
114
+ // If this operation is expected to take longer than 0.5 seconds, the task must
115
+ // supply a progress response to Cortana before starting the operation, and
116
+ // updates must be provided at least every 5 seconds.
117
+ string loadingTripToDestination = string .Format (
118
+ cortanaResourceMap .GetValue (" LoadingTripToDestination" , cortanaContext ).ValueAsString ,
119
+ destination );
120
+ await ShowProgressScreen (loadingTripToDestination );
121
+ Model .TripStore store = new Model .TripStore ();
122
+ await store .LoadTrips ();
123
+
124
+ // Query for the specified trip.
127
125
// The destination should be in the phrase list. However, there might be
128
126
// multiple trips to the destination. We pick the first.
129
- IEnumerable < Model .Trip > trips = store .Trips .Where (p => p .Destination == destination );
130
-
131
- var userMessage = new VoiceCommandUserMessage ();
132
- var destinationsContentTiles = new List <VoiceCommandContentTile >();
133
- if (trips .Count () == 0 )
134
- {
135
- string foundNoTripToDestination = string .Format (
136
- cortanaResourceMap .GetValue (" FoundNoTripToDestination" , cortanaContext ).ValueAsString ,
137
- destination );
138
- userMessage .DisplayMessage = foundNoTripToDestination ;
139
- userMessage .SpokenMessage = foundNoTripToDestination ;
140
- }
141
- else
142
- {
143
- // Set plural or singular title.
144
- string message = " " ;
145
- if (trips .Count () > 1 )
146
- {
147
- message = cortanaResourceMap .GetValue (" PluralUpcomingTrips" , cortanaContext ).ValueAsString ;
148
- }
149
- else
150
- {
151
- message = cortanaResourceMap .GetValue (" SingularUpcomingTrip" , cortanaContext ).ValueAsString ;
152
- }
153
- userMessage .DisplayMessage = message ;
154
- userMessage .SpokenMessage = message ;
155
-
156
- // Define a tile for each destination.
157
- foreach (Model .Trip trip in trips )
158
- {
159
- int i = 1 ;
160
-
161
- var destinationTile = new VoiceCommandContentTile ();
162
-
163
- destinationTile .ContentTileType = VoiceCommandContentTileType .TitleWith68x68IconAndText ;
164
- destinationTile .Image = await StorageFile .GetFileFromApplicationUriAsync (new Uri (" ms-appx:///AdventureWorks.VoiceCommands/Images/GreyTile.png" ));
165
-
166
- destinationTile .AppLaunchArgument = trip .Destination ;
167
- destinationTile .Title = trip .Destination ;
168
- if (trip .StartDate != null )
169
- {
170
- destinationTile .TextLine1 = trip .StartDate .Value .ToString (dateFormatInfo .LongDatePattern );
171
- }
172
- else
173
- {
174
- destinationTile .TextLine1 = trip .Destination + " " + i ;
175
- }
176
-
177
- destinationsContentTiles .Add (destinationTile );
178
- i ++ ;
179
- }
180
- }
181
-
182
- var response = VoiceCommandResponse .CreateResponse (userMessage , destinationsContentTiles );
183
-
184
- if (trips .Count () > 0 )
185
- {
186
- response .AppLaunchArgument = destination ;
187
- }
188
-
189
- await voiceServiceConnection .ReportSuccessAsync (response );
127
+ IEnumerable < Model .Trip > trips = store .Trips .Where (p => p .Destination == destination );
128
+
129
+ var userMessage = new VoiceCommandUserMessage ();
130
+ var destinationsContentTiles = new List <VoiceCommandContentTile >();
131
+ if (trips .Count () == 0 )
132
+ {
133
+ string foundNoTripToDestination = string .Format (
134
+ cortanaResourceMap .GetValue (" FoundNoTripToDestination" , cortanaContext ).ValueAsString ,
135
+ destination );
136
+ userMessage .DisplayMessage = foundNoTripToDestination ;
137
+ userMessage .SpokenMessage = foundNoTripToDestination ;
138
+ }
139
+ else
140
+ {
141
+ // Set plural or singular title.
142
+ string message = " " ;
143
+ if (trips .Count () > 1 )
144
+ {
145
+ message = cortanaResourceMap .GetValue (" PluralUpcomingTrips" , cortanaContext ).ValueAsString ;
146
+ }
147
+ else
148
+ {
149
+ message = cortanaResourceMap .GetValue (" SingularUpcomingTrip" , cortanaContext ).ValueAsString ;
150
+ }
151
+ userMessage .DisplayMessage = message ;
152
+ userMessage .SpokenMessage = message ;
153
+
154
+ // Define a tile for each destination.
155
+ foreach (Model .Trip trip in trips )
156
+ {
157
+ int i = 1 ;
158
+
159
+ var destinationTile = new VoiceCommandContentTile ();
160
+
161
+ destinationTile .ContentTileType = VoiceCommandContentTileType .TitleWith68x68IconAndText ;
162
+ destinationTile .Image = await StorageFile .GetFileFromApplicationUriAsync (new Uri (" ms-appx:///AdventureWorks.VoiceCommands/Images/GreyTile.png" ));
163
+
164
+ destinationTile .AppLaunchArgument = trip .Destination ;
165
+ destinationTile .Title = trip .Destination ;
166
+ if (trip .StartDate != null )
167
+ {
168
+ destinationTile .TextLine1 = trip .StartDate .Value .ToString (dateFormatInfo .LongDatePattern );
169
+ }
170
+ else
171
+ {
172
+ destinationTile .TextLine1 = trip .Destination + " " + i ;
173
+ }
174
+
175
+ destinationsContentTiles .Add (destinationTile );
176
+ i ++ ;
177
+ }
178
+ }
179
+
180
+ var response = VoiceCommandResponse .CreateResponse (userMessage , destinationsContentTiles );
181
+
182
+ if (trips .Count () > 0 )
183
+ {
184
+ response .AppLaunchArgument = destination ;
185
+ }
186
+
187
+ await voiceServiceConnection .ReportSuccessAsync (response );
190
188
}
191
189
```
192
190
@@ -203,7 +201,7 @@ userMessage.SpokenMessage =
203
201
" You have one trip to Vegas coming up." ;
204
202
205
203
response = VoiceCommandResponse .CreateResponse (userMessage );
206
- response .AppLaunchArgument = “ Las Vegas ” ;
204
+ response .AppLaunchArgument = " Las Vegas" ;
207
205
await VoiceCommandServiceConnection .RequestAppLaunchAsync (response );
208
206
```
209
207
0 commit comments