How to enable device capabilities (XAML)

This tutorial describes how to declare device capabilities in Microsoft Visual Studio. This enables your app to use cameras, microphones, location sensors, and other devices.

What you need to know

Technologies

  • Windows Runtime

Prerequisites

  • Visual Studio

Instructions

Step 1: Specify the device capabilities your app will use

Windows Store apps and Windows Phone Store apps require you to specify in the app package manifest when you use certain types of devices. In Visual Studio, you can declare most capabilities by using Manifest Designer or you can add them manually as described in How to specify device capabilities in a package manifest (manually). This tutorial assumes you're using Manifest Designer.

  1. In Visual Studio Solution Explorer, double-click the package manifest file, Package.appxmanifest.

  2. Open the Capabilities tab.

  3. Select the device capabilities that your app uses. If you don't see the capability you're looking for in Manifest Designer, add it manually. For more info, see How to specify device capabilities in a package manifest.

Device Capability Manifest Designer Description
Location Provides access to the current location. This is obtained from dedicated hardware like a GPS sensor in the PC, or derived from available network information.
Microphone Provides access to the microphone's audio feed. This allows the app to record from connected microphones.
Proximity Provides the capability to connect to devices in close proximity to the PC via near-field communication (NFC). Near-field proximity may be used to send files or communicate with an app on the nearby device.
Webcam Provides access to the built-in camera or attached webcam's video feed. This allows the app to capture snapshots and movies.
USB Provides access to custom USB devices. This capability requires child elements. This feature is not supported on Windows Phone.
Human Interface Device (HID) Provides access to Human Interface Devices (HID). This capability requires child elements. For more info, see How to specify device capabilities for HID.
Bluetooth GATT Provides access to Bluetooth LE devices through a collection of primary services, included services, characteristics, and descriptors. This capability requires child elements. For more info, see How to specify device capabilities for Bluetooth.
Bluetooth RFCOMM Provides access to APIs that support the Basic Rate/Extended Data Rate (BR/EDR) transport and also lets your Windows Store app access a device that implements Serial Port Profile (SPP). This capability requires child elements. For more info, see How to specify device capabilities for Bluetooth.
pointOfService Provides access to Point of Service (POS) barcode scanners and magnetic stripe readers. This feature is not supported on Windows Phone.
 

Step 2: Use the Windows Runtime API for communicating with your device

The following table lists the Windows Runtime APIs to use with each device capability.

Device Capability API
Location

See Detecting geolocation for tutorials.

Microphone

See Adding Multimedia to your app for tutorials.

Proximity See Supporting proximity and tapping for tutorials.
Webcam

See Adding Multimedia to your app for tutorials.

USB Windows.Devices.Usb Not supported on Windows Phone.
HID Windows.Devices.HumanInterfaceDevice
Bluetooth GATT Windows.Devices.Bluetooth.GenericAttributeProfile
Bluetooth RFCOMM Windows.Devices.Bluetooth.Rfcomm
Point of Service (POS) Windows.Devices.PointOfService Not supported on Windows Phone.

 

Remarks

Note that some types of devices, such as printers, scanners, and sensors, don't need to be declared in the app package manifest.

DeviceCapability element reference

App capability declarations

How to specify device capabilities in a package manifest (manually)

Accessing Content on Removable Storage