毎度のお約束、本記事はプレビュー状態のOS、IDE、SDKを利用しております。製品版では異なる可能性があります。
本記事はWindows 10向けのユニバーサルWindowsアプリについて学んだことを残して行く記事です。
これまでの記事はカテゴリ「UWP(Win 10) Preview」を参照ください。
Universal Windows Platformでは一つのプロジェクト、一つのバイナリでデスクトップ(ストアアプリ)、モバイル(Windows Phone)など様々な環境に向けたアプリケーションを作成することができます。とはいえ、ある環境でしか使えない機能を使いたい場合があります。
その場合は環境毎の拡張SDKを追加することになります。
Windowsストアアプリに無くて、Windows Phoneで利用可能な機能といえば、戻るボタン「Windows.Phone.UI.Input.HardwareButtons」があります。
初期プロジェクトではWindows.Phone.UI.Input.HardwareButtonsは利用できないので参照を追加する必要があります。
Windows Phone向けの拡張は参照の追加より「Windows Mobile Extention SDK for the UWP」を追加します。
下記画像だと似たような名前のSDKがありますが、おそらくプレビュー版のSDKのバージョン違い版かなと推測。
これでWindows.Phone.UI.Input.HardwareButtonsが利用できるようになりました。
ストアアプリにあってWindows Phoneに無い機能といえばCameraCaptureUIがあります(後述しますが、Windows 10 MobileではCameraCaptureUIを利用したコードが動作しました? 対応した?)。
こちらも初期プロジェクトではAPIが見つからないので、参照を追加してあげます。
「Windows Desktop Extention for the UWP」を追加することで利用可能になります。
・・・と書いた後に実際に端末でデバッグするとWindows 10 MobileでもCameraCaptureUIを利用したコードが普通に動いてしまいました。8.1の頃はこのAPIはストアアプリのみだった気がするのですが思い違いかも・・・。
ApiInformation.IsTypePresent(“Windows.Media.Capture.CameraCaptureUI”)の結果もWindows Phone上でもtrueになりました。まだまだ理解不足です。
拡張のパスを調べると私の環境では「C:\Program Files (x86)\Windows Kits\10\Extension SDKs\WindowsDesktop\10.0.10158.0」でした(デスクトップ拡張の場合)。
該当のパスには「SDKManifest.xml」があり、拡張APIの概要を見ることができます。
<?xml version="1.0" encoding="UTF-8"?> -<FileList MoreInfo="http://go.microsoft.com/fwlink/?LinkId=517639" SupportPrefer32Bit="True" TargetFramework=".NETCore, version=v4.5.3;" SupportsMultipleVersion="Error" ProductFamilyName="Windows.Desktop" MinVSVersion="14.0" AppliesTo="WindowsAppContainer" DisplayName="Microsoft Desktop Extension SDK for Universal App Platform" SDKType="Platform" TargetPlatformVersion="10.0.10069.0" TargetPlatformMinVersion="10.0.0.1" TargetPlatform="UAP"> -<ContainedApiContracts> <ApiContract version="1.0.0.0" name="Windows.ApplicationModel.Activation.ActivatedEventsContract"/> <ApiContract version="1.0.0.0" name="Windows.ApplicationModel.Activation.ContactActivatedEventsContract"/> <ApiContract version="1.0.0.0" name="Windows.ApplicationModel.Activation.WebUISearchActivatedEventsContract"/> <ApiContract version="1.0.0.0" name="Windows.ApplicationModel.Calls.LockScreenCallContract"/> <ApiContract version="1.0.0.0" name="Windows.ApplicationModel.Resources.Management.ResourceIndexerContract"/> <ApiContract version="1.0.0.0" name="Windows.ApplicationModel.Search.SearchContract"/> <ApiContract version="1.0.0.0" name="Windows.ApplicationModel.Wallet.WalletContract"/> <ApiContract version="1.0.0.0" name="Windows.Devices.Custom.CustomDeviceContract"/> <ApiContract version="1.0.0.0" name="Windows.Devices.Portable.PortableDeviceContract"/> <ApiContract version="1.0.0.0" name="Windows.Devices.Printers.Extensions.ExtensionsContract"/> <ApiContract version="1.0.0.0" name="Windows.Devices.Printers.PrintersContract"/> <ApiContract version="1.0.0.0" name="Windows.Devices.Scanners.ScannerDeviceContract"/> <ApiContract version="1.0.0.0" name="Windows.Devices.Sms.LegacySmsApiContract"/> <ApiContract version="1.0.0.0" name="Windows.Graphics.Printing3D.Printing3DContract"/> <ApiContract version="1.0.0.0" name="Windows.Management.Workplace.WorkplaceSettingsContract"/> <ApiContract version="1.0.0.0" name="Windows.Media.Capture.AppCaptureContract"/> <ApiContract version="1.0.0.0" name="Windows.Media.Capture.CameraCaptureUIContract"/> <ApiContract version="1.0.0.0" name="Windows.Media.Devices.CallControlContract"/> <ApiContract version="1.0.0.0" name="Windows.Media.MediaControlContract"/> <ApiContract version="1.0.0.0" name="Windows.Media.Playlists.PlaylistsContract"/> <ApiContract version="1.0.0.0" name="Windows.Media.Protection.ProtectionRenewalContract"/> <ApiContract version="1.0.0.0" name="Windows.Networking.NetworkOperators.LegacyNetworkOperatorsContract"/> <ApiContract version="1.0.0.0" name="Windows.Networking.NetworkOperators.NetworkOperatorsTetheringContract"/> <ApiContract version="1.0.0.0" name="Windows.Security.EnterpriseData.EnterpriseDataContract"/> <ApiContract version="1.0.0.0" name="Windows.Security.ExchangeActiveSyncProvisioning.EasContract"/> <ApiContract version="1.0.0.0" name="Windows.System.UserProfile.UserProfileContract"/> <ApiContract version="1.0.0.0" name="Windows.UI.ApplicationSettings.ApplicationsSettingsContract"/> <ApiContract version="1.0.0.0" name="Windows.UI.Core.AnimationMetrics.AnimationMetricsContract"/> <ApiContract version="1.0.0.0" name="Windows.UI.Xaml.Hosting.HostingContract"/> </ContainedApiContracts> </FileList>
眺めているとなんとなく固有の機能が想像できますね。
Please give us your valuable comment