23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Target Apps<br />

Looking back to Figure 12-1, we can see that while the interaction between a source app and the share<br />

broker is driven by the single datarequested event, the interaction between the broker and a target<br />

app is a little more involved. For one, the broker needs to determine which apps can potentially handle<br />

a particular data package, for which purpose each target app includes appropriate details in its manifest.<br />

When an app is selected, it gets launched with an activation kind of shareTarget, in response to which it<br />

should show a specific share UI rather than the full app experience.<br />

Let’s see how all this works with the Sharing content target app sample whose appearance is shown<br />

in Figure 12-2 (borrowing from Figure 2-22 we saw ages ago). Be sure to run this app once in Visual<br />

Studio so that it’s effectively installed and it will appear on the list of apps when we invoke the Share<br />

charm.<br />

FIGURE 12-2 The appearance of the Sharing content target app sample (the right-hand nonfaded part).<br />

The first step for a share target is to declare the data formats it can accept in the Declarations section<br />

of its manifest, along with the page that will be invoked when the app is selected as a target. As shown<br />

in Figure 12-3, the target app sample declares it can handle text, URI, bitmap, html, and the<br />

http://schema.org/Book formats, and it also declares it can handle whatever files might be in a data<br />

package (you can indicate specific file types here). Way down at the bottom it then points to target.html<br />

as its Share target page.<br />

502

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

Saved successfully!

Ooh no, something went wrong!