AutoPlay for Windows Store device apps in Windows 8.1
In Windows 8.1, device manufacturers can specify their Windows Store device app as an AutoPlay handler for their device. They can also let other Windows Store apps act as AutoPlay handlers for their device. This topic describes how to use the Device Metadata Authoring Wizard to enable AutoPlay. It also describes how to handle AutoPlay activations in your app. For more info about device apps, see Meet Windows Store device apps.
Note You don't need to use device metadata for all types of AutoPlay. Without device metadata, AutoPlay lets you provide your app as an option when a user connects a device to a PC. This includes non-volume devices like a camera or media player, or volume devices like a USB thumb drive, SD card, or DVD. AutoPlay also lets you register your app as an option when users share files between two machines by using Proximity (tapping). But your app can't install automatically without device metadata. For more info about using AutoPlay when device metadata isn't required, see Auto-launching with AutoPlay.
Depending on the version of your app, you can enable AutoPlay in these ways:
- Only your Windows Store device app can handle AutoPlay activation for your device [supported in Windows 8, Windows 8.1].
- Other Windows Store apps can handle AutoPlay activation for your device [supported in Windows 8.1 only].
- Your Windows Store device app and other Windows Store apps can handle AutoPlay activation for your device [supported in Windows 8.1 only].
This example shows an AutoPlay dialog for an app named Contoso Dashboard that has registered as the AutoPlay handler for the Contoso Pedometer device:
When using device metadata with your app, AutoPlay supports these device types:
|Device class||AutoPlay supported in Windows 8||AutoPlay supported in Windows 8.1|
|Digital still camera|
|Digital video camcorder|
|Portable media player|
|Human Interface Device (HID)|
|Printers, scanners, fax|
Make sure you have the Device Metadata Authoring Wizard. You'll need it to enable AutoPlay. In this release, this wizard is included with Microsoft Visual Studio Professional 2013 and Microsoft Visual Studio Ultimate 2013. But if you have Microsoft Visual Studio Express 2013 for Windows, you need to download the standalone SDK for Windows 8.1 to get the wizard.
Associate your app with the Windows Store. You'll need your app's package information to enable AutoPlay. For more info, see the Associate your app with the Windows Store section in Step 1: Create a Windows Store device app.
The Device Metadata Authoring Wizard lets you declare your Windows Store app to be the default AutoPlay handler for your device. You can also let other Windows Store apps act as AutoPlay handlers for your device. You can choose either of these options or both of these options.
To enable AutoPlay with the Device Metadata Authoring Wizard
- Start the Device Metadata Authoring Wizard from %ProgramFiles(x86)%\Windows Kits\8.1\bin\x86, by double-clicking DeviceMetadataWizard.exe.
- Click Edit Device Metadata. This will let you edit your existing device metadata package.
- In the Open dialog box, locate the device metadata package associated with your Windows Store device app. (It has a devicemetadata-ms file extension.)
- (Optional.) If you don't have your device app's Package name, Publisher name, and App ID handy, click App Info to view the packaging information for your Windows Store device app.
- Click Windows Info to specify AutoPlay details.
- If you want to specify an app to be the default AutoPlay handler for your device, select Use a Windows Store device app. You can select any Windows Store app or Windows Store device app, but that app must handle the AutoPlay activation for your device and specify the corresponding experience ID in the app package manifest (as specified in the next procedure).
- Package name: In the app package manifest, this is the Name attribute of the Identity element.
- Publisher name: In the app package manifest, this is the Publisher attribute of the Identity element.
- App ID: In the app package manifest, this is the ID attribute of the Application element.
- Verb: This is the identifier for the AutoPlay activation. Your app will use it to determine if the activation came from your device. You can use any value for the Verb setting, except for open, which is reserved.
- AutoPlay event type: Leave this as Device. In the device metadata, the wizard will automatically specify the experience ID associated with your Windows Store device app.
- If you want to let other apps act as AutoPlay handlers for your device, select Enable AutoPlay for registered apps.
- When you're done, click Next.
- When you see the Finish page, write down the Experience ID. You'll need it in the next procedure, when you handle the AutoPlay activation in your app.
- Verify your Save information and click Save to update your device metadata package.
To handle an AutoPlay activation in your app, you need to register for a
windows.autoPlayDevice extension in the app package manifest and then handle that event in the
OnActivated event of the Application object. Note that your app can register as an AutoPlay handler for multiple devices.
To register your app as an AutoPlay handler for your device, you need to specify the experience ID associated with your Windows Store device app and the AutoPlay Verb and ActionDisplayName that will be used to activate your app.
- Open your app's project in Microsoft Visual Studio 2013.
- In Solution Explorer, right-click the Package.appxmanifest file and select View Code. This will display the app package manifest in the XML (Text) Editor.
- In the
Applicationelement, below the
VisualElementselement, paste the following
Extensionselement into your package manifest file.
- Replace the AutoPlay values from this example with the actual values for your app:
Verb: This is the identifier for the AutoPlay activation. Your app will use it to determine if the activation came from your device. If your app was specified as the default AutoPlay handler for your device, this value should match the Verb that you specified in the device metadata. If your app was not specified as the default AutoPlay handler for your device, you can use any value for the Verb setting, except for open, which is reserved.
ActionDisplayName: The string that AutoPlay displays for your app.
Experience ID: The experience ID GUID that associates your app with your device. This is the value that you wrote down in the previous procedure.
When your device triggers an AutoPlay activation, the activation kind will be
Windows.ApplicationModel.Activation.ActivationKind.device. Use the
eventObj object passed by
OnActivated to check how your app was activated. If it was from AutoPlay, you can use
eventObj to determine which device ID and AutoPlay verb caused the activation.
In this example, the activation event parameter (eventObj) carries the device's ID as well as the verb for activation.
- Meet Windows Store device apps
- Build a Windows Store device app step-by-step
- Auto-launching with AutoPlay
- Launching, resuming, and multitasking