啟用裝置功能Enable device capabilities

本教學課程描述如何在 Microsoft Visual Studio 中宣告裝置功能。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.

指定您 app 將要使用的裝置功能Specify the device capabilities your app will use

當您使用特定類型的裝置時,Windows app 需要您在 app 套件資訊清單中指定。Windows apps require you to specify in the app package manifest when you use certain types of devices. 在 Visual Studio 中,您可以使用資訊清單設計工具宣告大多數的功能,或是如同如何在套件資訊清單中指定裝置功能 (手動) 中所述的方式,手動新增它們。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.

注意   某些類型的裝置(例如印表機、掃描器和感應器)不需要在應用程式套件資訊清單中宣告。Note   Some types of devices, such as printers, scanners, and sensors, don't need to be declared in the app package manifest.

  • 在 Visual Studio [方案總管] 中,按兩下套件資訊清單檔案 Package.appxmanifestIn Visual Studio Solution Explorer, double-click the package manifest file, Package.appxmanifest.
  • 開啟 [功能] 索引標籤。Open the Capabilities tab.
  • 選取您的應用程式使用的裝置功能。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
AllJoynAllJoyn 資訊清單設計工具中提供 讓網路上具備 AllJoyn 功能的 app 和裝置能夠進行探索且與彼此互動。Allows AllJoyn-enabled apps and devices on a network to discover and interact with each other. 存取 Windows.Devices.AllJoyn 命名空間中之 API 的所有 app 都必須使用這個功能。App apps that access APIs in the Windows.Devices.AllJoyn namespace must use this capability.
封鎖的聊天訊息Blocked Chat Messages 資訊清單設計工具中提供 讓 app 能夠讀取已由垃圾郵件篩選 app 封鎖的 SMS 和 MMS 訊息。Allows apps to read SMS and MMS messages that have been blocked by the Spam Filter app.
輸入聊天存取Chat Message Access 資訊清單設計工具中提供 讓 app 能夠讀取及刪除文字訊息。Allows apps to read and delete Text Messages. 它也能讓 app 將聊天訊息儲存於系統資料存放區中。It also allows apps to store chat messages in the system data store.
程式碼產生Code Generation 資訊清單設計工具中提供 讓 app 能夠動態產生程式碼。Allows apps to generate code dynamically.
企業驗證Enterprise Authentication 資訊清單設計工具中提供 這個功能會受限於 Microsoft Store 原則。This capability is subject to the Microsoft Store policy. 它提供可連線至需要網域認證之企業內部網路資源的功能。It provides the capability to connect to enterprise intranet resources that require domain credentials. 大部分的 app 通常不太需要用到這個功能。This capability is not typically needed for most apps.
網際網路 (用戶端)Internet (Client) 資訊清單設計工具中提供 提供公共場所的網際網路與網路的對外存取,例如機場與咖啡廳。Provides outbound access to the Internet and networks in public places like airports and coffee shops. 例如,使用者指定網路為公用的內部網路位置。For example, Intranet networks where the user has designated the network as public. 大部分需要網際網路存取的 app 都應使用此功能。Most apps that require Internet access should use the capability.
網際網路 (用戶端 & 伺服器)Internet (Client & Server) 資訊清單設計工具中提供 在公共場所 (例如機場與咖啡廳) 提供網際網路與網路的對內及對外存取。Provides inbound and outbound access to the Internet and the networks in public places like airports and coffee shops. 這個功能是網際網路 (用戶端) 的超集。This capability is a superset of Internet (Client). 如果已啟用此功能,則網際網路 (用戶端) 不需要經過啟用。Internet (Client) doesn't need to be enabled if this capability is also enabled. 一律封鎖對重要連接埠的輸入存取。Inbound access to critical ports is always blocked.
LocationLocation 資訊清單設計工具中提供 提供目前位置的存取。Provides access to the current location. 這是透過專用硬體 (如電腦中的 GPS 感應器) 取得或由可用的網路資訊衍生的位置。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. 這樣可讓 app 從連接的麥克風錄音。This allows the app to record from connected microphones.
音樂媒體櫃Music Library 資訊清單設計工具中提供 提供在本機電腦和 HomeGroup 電腦中,新增、變更或刪除音樂媒體櫃中檔案的功能。Provides the capability to add, change, or delete files in the Music Library for the local PC and HomeGroup PCs.
物件 3DObjects 3D 資訊清單設計工具中提供 讓使用者以程式設計方式存取他們的 [立體物件],允許 app 在沒有使用者互動的情況下,列舉和存取媒體櫃中的所有檔案。Provides programmatic access to the user's 3D Objects, allowing the app to enumerate and access all files in the library without user interaction. 這項功能通常用於必須存取整個 [立體物件] 庫的 3D app 和遊戲。This capability is typically used in 3D apps and games that need to access the entire 3D Objects library.
撥打電話Phone Call 資訊清單設計工具中提供 讓 app 能夠存取所有裝置上的電話線路,並執行下列功能:在無需提示使用者的情況下,在手機上撥打電話並顯示系統撥號程式、存取與線路相關的中繼資料、存取與線路相關的觸發程序。Allows apps to access all of the phone lines on the device and perform the following functions: place a call on the phone and show the system dialer without prompting the user; access line-related metadata; access line-related triggers. 讓使用者選取的垃圾電話篩選 app 能夠設定和檢查封鎖清單及通話來源資訊。Allows the user-selected spam filter app to set and check the block list and call origin information.
圖片媒體櫃Pictures Library 資訊清單設計工具中提供 提供在本機電腦和 HomeGroup 電腦中,新增、變更或刪除圖片媒體櫃中檔案的功能。Provides the capability to add, change, or delete files in the Pictures Library for the local PC and HomeGroup PCs.
服務點Point of Service 資訊清單設計工具中提供 提供服務點週邊設備存取權。Provides access to Point of Service peripherals. 需要具備這個功能,才能存取 Windows.Devices.PointOfService 命名空間中的 API。This capability is required to access APIs in the Windows.Devices.PointOfService namespace.
私人網路 (用戶端 & 伺服器)Private Networks (Client & Server) 資訊清單設計工具中提供 提供對內和對外存取權限給具有已驗證網域控制站或使用者已指定為家用或工作場所網路的內部網路。Provides inbound and outbound access to Intranet networks that have an authenticated domain controller, or that the user has designated as either home or work networks. 一律封鎖對重要連接埠的輸入存取。Inbound access to critical ports is always blocked.
鄰近Proximity 資訊清單設計工具中提供 提供透過近距離無線通訊 (NFC) 將鄰近裝置連線到電腦的能力。Provides the capability to connect to devices in close proximity to the PC via near-field communication (NFC). 近距離鄰近性可用來傳送檔案或與鄰近裝置上的 app 通訊。Near-field proximity may be used to send files or communicate with an app on the nearby device.
卸除式存放裝置Removable Storage 資訊清單設計工具中提供 提供新增、變更或刪除卸除式存放裝置上檔案的功能。Provides the capability to add, change, or delete files on removable storage devices. app 在抽取式存放裝置上可以存取的檔案類型,只有在資訊清單中使用檔案類型關聯宣告所定義的檔案類型。The app can only access the file types on removable storage that are defined in the manifest using the File Type Associations declaration. app 無法存取 HomeGroup 電腦上的抽取式存放裝置。The app can't access removable storage on HomeGroup PCs.
共用使用者憑證Shared User Certificates 資訊清單設計工具中提供 這個功能會受限於 Microsoft Store 原則。This capability is subject to the Microsoft Store policy. 它提供存取軟體和硬體憑證 (例如智慧卡憑證),進行使用者身分識別驗證的功能。It provides the capability to access software and hardware certificates, such as smart card certificates, for validating a user's identity. 系統會在執行階段中叫用相關的 API,使用者必須採取動作 (插入卡、選取憑證等)。When related APIs are invoked at runtime, the user must take action (insert card, select certificate, etc.). 如果您的 app 包含透過 Certificates 宣告的私密憑證,則不需要這個功能。This capability is not necessary if your app includes a private certificate via a Certificates declaration.
使用者帳戶資訊User Account Information 資訊清單設計工具中提供 提供 app 存取使用者名稱和圖片的能力。Gives apps the ability to access the user's name and picture. 您需要具備這個功能,才能存取 Windows.System.UserProfile 命名空間中的某些 API。This capability is required to access some APIs in the Windows.System.UserProfile namespace.
視訊庫Videos Library 資訊清單設計工具中提供 提供在本機電腦和 HomeGroup 電腦中,新增、變更或刪除視訊庫中檔案的功能。Provides the capability to add, change, or delete files in the Videos Library for the local PC and HomeGroup PCs.
VOIP 通話VOIP Calling 資訊清單設計工具中提供 讓 app 能夠在 Windows.ApplicationModel.Calls 命名空間中存取 VOIP 通話 API。Allows apps to access the VOIP calling APIs in the Windows.ApplicationModel.Calls namespace.
網路攝影機Webcam 資訊清單設計工具中提供 提供存取內建相機或連接的網路攝影機的視訊輸出。Provides access to the built-in camera or attached webcam's video feed. 這可讓應用程式擷取快照和影片。This allows the app to capture snapshots and movies.
USBUSB 提供自訂 USB 裝置的存取。Provides access to custom USB devices. 此功能需要子元素。This capability requires child elements. Windows Phone 不支援此功能。This feature is not supported on Windows Phone.
人性化介面裝置 (HID)Human Interface Device (HID) 提供人性化介面裝置 (HID) 的存取。Provides access to Human Interface Devices (HID). 此功能需要子元素。This capability requires child elements. 如需詳細資訊,請參閱如何指定 HID 的裝置功能For more info, see How to specify device capabilities for HID.
藍牙 GATTBluetooth GATT 透過主要服務的集合 (包括服務、特性和描述元),提供藍牙 LE 裝置的存取。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.
藍牙 RFCOMMBluetooth RFCOMM 提供可支援基本速率/延伸資料速率 (BR/EDR) 傳輸之 API 的存取,也讓您的 UWP app 存取可實作序列埠設定檔 (SPP) 的裝置。Provides access to APIs that support the Basic Rate/Extended Data Rate (BR/EDR) transport and also lets your UWP 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.

使用 Windows 執行階段 API 與您的裝置進行通訊Use the Windows Runtime API for communicating with your device

下表會將部份功能連線到 Windows 執行階段 API。The following table connects some of the capabilities to Windows Runtime APIs.

裝置功能Device Capability APIAPI
AllJoynAllJoyn Windows.Devices.AllJoynWindows.Devices.AllJoyn
封鎖的聊天訊息Blocked Chat Messages Windows.ApplicationModel.CommunicationBlockingWindows.ApplicationModel.CommunicationBlocking
LocationLocation 如需詳細資訊,請參閱地圖與位置概觀See Maps and location overview for more information.
撥打電話Phone Call ApplicationModel 呼叫Windows.ApplicationModel.Calls
使用者帳戶資訊User Account Information Windows.System。UserProfileWindows.System.UserProfile
VOIP 通話VOIP Calling ApplicationModel 呼叫Windows.ApplicationModel.Calls
USBUSB Windows.Devices.UsbWindows.Devices.Usb
HIDHID Windows.Devices.HumanInterfaceDeviceWindows.Devices.HumanInterfaceDevice
藍牙 GATTBluetooth GATT GenericAttributeProfile。Windows.Devices.Bluetooth.GenericAttributeProfile
藍牙 RFCOMMBluetooth RFCOMM Windows.Devices.Bluetooth.RfcommWindows.Devices.Bluetooth.Rfcomm
服務點Point of Service Windows.Devices.PointOfServiceWindows.Devices.PointOfService