49 out of 63 rated this helpful - Rate this topic

App contracts and extensions (Windows Store apps)

[This topic is featured in Develop great apps for Windows 8.]

Windows Store apps use contracts and extensions to declare the interactions that they support with other apps. These apps must include required declarations in the package manifest and call required Windows Runtime APIs to communicate with Windows and other contract participants.

Contracts A contract is like an agreement between one or more apps. Contracts define the requirements that apps must meet to participate in these unique Windows interactions.

For example, Windows lets users share content from one app to another. The app that shares content out supports a source contract by meeting specific requirements, while the app that receives the shared content supports a target contract by meeting a different set of requirements. Neither app needs to know anything about the other. Every app that participates in the sharing contract can be confident that the sharing workflow is completely supported, end-to-end, by Windows.

Extensions An extension is like an agreement between an app and Windows. Extensions lets app developers extend or customize standard Windows features primarily for use in their apps and potentially for use in other apps.

Use the package manifest to declare extensions. For example, an app can declare that it handles files with certain file extensions, or it can declare that it uses a particular dynamic-link library. In Visual Studio, use the Declarations tab. If you are creating the package manually, see the Extensions element.

These next sections describe the built-in app contracts and extensions that Windows 8 supports.

Account picture provider (extension)

When users decide to change their account picture, they can either select an existing picture or use an app to take a new one. If your app can take pictures, you can use this extension to have Windows list your app in the Account Picture Settings control panel. From there, users can select it to create a new account picture.

For more info about this extension, see the UserInformation reference topic. You can also check out our Account picture name sample.

AutoPlay (extension)

When the user connects a device to a computer, Windows fires an AutoPlay event. This extension enables your app to be listed as an AutoPlay choice for the one or more AutoPlay events.

For more info about this extension, see Auto-launching with AutoPlay.

Background tasks (extension)

Apps can use background tasks to run app code even when the app is suspended. Background tasks are intended for small work items that require no interaction with the user.

For more info, see Introduction to background tasks.

Cached file updater contract

You can provide updates for particular files to help users who want to use your app as a central repository to track and maintain files. For example, Microsoft SkyDrive can track a file to ensure that the user sees the latest version of the file and trigger updates to the file if the SkyDrive app can provide a newer version. Additionally, if the user saves a newer version of a tracked file, SkyDrive can trigger an update to its version of the file to ensure that SkyDrive always has the newest version.

See Accessing files with file pickers and Providing file services from file pickers.

Camera settings (extension)

Your app can provide a custom user interface for selecting camera options and choosing effects when a camera is used to capture photos or video.

For more info about this extension, see Developing Windows Store device apps for cameras.

Contact picker (extension)

This extension enables your app to register to provide contact data. Your app is included in the list of apps that Windows displays whenever the user needs access to their contacts.

For more info about this extension, see the Windows.ApplicationModel.Contacts.Provider reference topic. You can also check out Managing user contacts.

File activation (extension)

Files that have the same file name extension are of the same file type. Your app can use existing, well known file types, such as .txt, or create a new file type. The file activation extension enables you to define a new file type or register to handle a file type.

See How to handle file activation.

File Open Picker contract

You can help users pick files from your app directly while they are using another app. Users gain freedom and flexibility to choose files that are stored and presented by apps.

Participating in this contract helps you increase the popularity and adoption of your app. For more info, see Accessing files with file pickers.

File Save Picker contract

You can help users save files to your app directly while they are using another app. Users gain freedom and flexibility to save files to your app so they can quickly and easily access the file when they switch to your app.

Participating in this contract helps you increase the popularity and adoption of your app. For more info, see Accessing files with file pickers.

Game Explorer (extension)

Your app can register with Windows as a game. To do this, you must create a Game Definition File (GDF), build it as a binary resource in your app, and declare that resource in the package manifest.

When you provide a GDF file for your game, Windows can limit access to the game when the user has enabled family safety features. For more info, see Creating a GDF file.

Play To contract

You can help your users play digital media to connected DLNA devices from within your app. Users tap the Connect charm and then the Play To button, confident that your app will play their media to the DLNA device.

Participating in this contract makes your app easy to use and encourages users to remain in your app for longer periods of time. For more info, see Streaming media to devices using Play To.

Print task settings (extension)

You can design an app that displays a custom print-related user interface and communicates directly with a print device. When you highlight the features that are specific to a particular make and model of print device, you can provide a richer, more enhanced user experience.

See Developing Windows Store device apps for printers.

Protocol activation (extension)

Your app can use existing protocols for communication, such as mailto, or create a custom protocol. The protocol activation extension enables you to define a custom protocol or register to handle an existing protocol.

See How to handle protocol activation.

Search contract

You can add a search pane to your app so users can search not only your app's content but content from other apps as well. Users can also transfer the search query itself to other apps. When you participate in this contract, you agree to make your app's content searchable by other participants and to present search results from those participants in your app.

Participating in this contract helps you gain traffic and usage for your app. For more info, see Adding search.

Settings contract

You can provide quick, in-context access to settings that affect the user's experience with your app.

Participating in this contract ensures that your app is consistent with the Windows settings model. For more info, see Adding app settings.

Share contract

You can help users share content from your app with another app or service, and vice versa. Participating in the Share contract means that you don't have to write extra code or provide other developers with an SDK for your app just to share content. Apps that support the Share contract can automatically share content to and from any other app that also supports the contract.

Participating in this contract helps you gain traffic and usage for your app. For more info, see Adding share.

SSL/certificates (extension)

Digital certificates are used to authenticate one entity to another. For example, certificates are often used to authenticate a user to web services over SSL. This extension enables you to install a digital certificate with your app.

See Encrypting data and working with certificates.

Hands-on labs

If you’d like to try working with contracts, extensions, and other key Windows 8 features, download the hands-on labs for Windows 8. These labs provide a modular, step-by-step introduction to creating a sample Windows Store app in the programming language of your choice (JavaScript and HTML or C# and XAML).

 

 

Build date: 6/11/2013

© 2013 Microsoft. All rights reserved.