检测当前设备(UWP)是否支持共享UI [英] Detect if share UI is supported in current device (UWP)

查看:98
本文介绍了检测当前设备(UWP)是否支持共享UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用c#/xaml为Windows 10设备创建了UWP应用.在应用程序中,我具有调用DataTransferManager.ShowShareUI()

I have created a UWP app for windows 10 devices using c#/xaml. In the app, i have a share functionality that calls DataTransferManager.ShowShareUI()

这在台式机,平板电脑和移动设备上可以正常工作.但是在我的xbox上,上述方法无法启动共享UI.它也不会抛出任何异常.在网上搜索了一下之后,我发现了这文章表示xbox不支持共享合同.并且没有显示共享UI.但这会带来糟糕的用户体验.

This works as expected on desktop, tablet and mobile devices. But on my xbox, the above method does not launch the share UI. Nor does it throw any exceptions. After searching online a bit, I found this article that says share contract is not supported on xbox. And no share UI is displayed. But this gives a bad user experience.

所以我现在有2个选择

  1. 如果设备是xbox,则隐藏共享"按钮
  2. 或者当用户单击共享时,显示一个不支持该功能的弹出窗口

经过数小时的搜索,我仍然没有找到一种可靠的方法来检测我的设备是否是xbox. Microsoft不鼓励尝试识别设备类型.相反,我们应该使用ApiInformation.IsTypePresentApiInformation.IsApiContractPresent检查API是否受支持.有关更多信息,请检查

After hours of searching, I have still not found a reliable way to detect if my device is xbox. Microsoft discourages trying to identify the device type. Instead we should check if the API is supported using either ApiInformation.IsTypePresent or ApiInformation.IsApiContractPresent. For more info check here

但就我而言,该API存在.因此,IsTypePresent返回true.我不确定在我的方案中应该为IsApiContractPresent传递什么参数.

But in my case, the API is present. So IsTypePresent returns true. I am not sure what parameter i should pass for IsApiContractPresent in my scenario.

简而言之,我需要一种可靠的方法来确定我的设备是否为xbox或确定我的设备是否支持共享UI.有人知道该怎么做吗?

In short, I need a reliable way either identify if my device is xbox or identify if share UI is supported in my device. Does anyone know how to do this?

推荐答案

Windows 10 RS1为DataTransferManager类引入了IsSupported方法:

Windows 10 RS1 introduced IsSupported method for DataTransferManager Class: Link

我相信您的Xbox设备已升级到RS1或更高版本,因此您可以使用此方法来检测该设备是否支持共享.

I believe your Xbox device has been upgraded to RS1 or later, so you can use this method to detect if the device supports sharing.

if (DataTransferManager.IsSupported())
{
      //Do sharing
}
else
{
      //Other thing
}

这篇关于检测当前设备(UWP)是否支持共享UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆