23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

At the very bottom of this UI you can also set a discrete start page for handling activations, but<br />

typically you’ll use your main activation handler, as shown in js/default.js of the Association launching<br />

sample (leading into js/scenario3.js).<br />

There you’ll receive the activation kind of file, in which case eventArgs.detail is a WebUIFile-<br />

ActivatedEventArgs: its files property contains the array of StorageFile objects from Windows.-<br />

System.Launcher.launchFileAsync, and its verb property will be "open". You respond, of course, by<br />

opening and presenting the file contents in whatever way is appropriate to the app.<br />

Of course, since the file might have come from anywhere, treat it as untrusted content, as we<br />

mentioned earlier for share targets. Avoid taking permanent actions based on those the file contents.<br />

As with the Search contract, too, be sure to test file activation when the app is already running and<br />

when it must be started anew. In all cases be sure to load app settings and restore session state if<br />

eventArgs.detail.previousExecutionState is terminated.<br />

Protocol Activation<br />

Creating a URI scheme association for an app is much like a file type association. In the Declarations<br />

section of the manifest, add a Protocol declaration, as shown in Figure 12-14.<br />

FIGURE 12-14 The Declarations > Protocol UI in the Visual Studio manifest designer.<br />

Under Properties, the Logo, Display Name, and Name all have the same meaning as with file type<br />

associations (see the previous section). Similarly, while you can specify a discrete start page, you’ll<br />

typically handle activation in your main activation handler, as demonstrated in again in js/default.js of<br />

the Association launching sample (leading into js/scenario4.js).<br />

There you’ll receive the activation kind of protocol, in which case eventArgs.detail is a<br />

WebUIProtocolActivatedEventArgs: its uri property contains the URI from Windows.System.-<br />

Launcher.launchUriAsync.<br />

529

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!