微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法让 Surface Duo 使用 Xamarin 使用两个屏幕

如何解决无法让 Surface Duo 使用 Xamarin 使用两个屏幕

我正在尝试为 Surface Duo 构建 Xamarin Forms 项目。项目运行,但不会同时使用两个屏幕。我按照 Xamarin for Surface Duo 的步骤操作 - 双屏 |微软文档:

  • 更新了指向 SDK 的指针。

  • Xamarin.Forms.DualScreen.DualScreenService.Init(this); 添加mainactivity.cs

  • 修改了活动缩写以包括ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.UiMode

  • 在 Android 应用中包含 Xamarin.DuoSdk 包。

  • 在阅读模拟器输出时,有一行建议使用 bcdedit 命令关闭 hyper-V,我就是这样做的。

  • 选定的 <build>(Android 10.0 – API 29)

我下载了一些示例(Sketch 360 和双屏演示),但没有成功让它们同时使用两个屏幕。我运行了 Get 上发布的演示,并更新了软件包,但没有运气。我检查了模拟器中的手机设置,看看是否有启用两个屏幕的设置,但没有找到任何东西。模拟器输出中有一些错误、警告,但不知道如何修复。

模拟器输出

emulator: Silencing all qWarning(); use qCWarning(...) instead: QT_LOGGING_RULES=default.warning=false
Failed to open /qemu.conf,err: 2
emulator: INFO: QtLogger.cpp:68: Critical: UpdatelayeredWindowIndirect Failed for ptDst=(1283,327),size=(700x21),dirty=(700x108 0,0) (A device attached to the system is not functioning.) ((null):0,(null))
emulator: INFO: QtLogger.cpp:68: Critical: UpdatelayeredWindowIndirect Failed for ptDst=(1283,dirty=(700x21 0,(null))
emulator: INFO: QtLogger.cpp:68: Critical: Uncaught TypeError: Cannot read property 'update' of undefined (qrc:/html/js/location-mock-web-channel.js:130,(null))

构建输出

system.invalidCastException: Unable to cast object of type 'Mono.Debugger.soft.PointerValue' to type 'Mono.Debugger.soft.PrimitiveValue'.
system.invalidCastException: Unable to cast object of type 'Mono.Debugger.soft.PointerValue' to type 'Mono.Debugger.soft.PrimitiveValue'.
system.invalidCastException: Unable to cast object of type 'Mono.Debugger.soft.PointerValue' to type 'Mono.Debugger.soft.PrimitiveValue'.
02-06 20:34:52.574 W/libc    ( 3873): Unable to set property "qemu.gles" to "1": connection Failed; errno=13 (Permission denied)
02-06 20:34:54.961 W/Openglrenderer( 3873): Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED,retrying without...

解决方法

如果您问的是如何让应用以编程方式使用两个屏幕,而不是用户在启动应用后执行操作,则无法做到。

请看这里的解释: https://docs.microsoft.com/en-us/dual-screen/introduction

当用户启动应用时,其核心窗口会最大化打开并占据单个屏幕的整个宽度和高度。

用户负责跨应用,这不是应用以编程方式进入的状态。

用户始终处于控制之中:为了避免给您的用户带来不可预测(或可能具有破坏性)的体验,应用不应在没有用户有意操作的情况下自动进入跨区状态。让用户决定。

,

运行 Surface Duo Emulator for Visual Studio 以启动 Surface Duo 模拟器。如果您对模拟器有任何问题,可以使用以下链接进行故障排除。 https://docs.microsoft.com/en-us/dual-screen/xamarin/use-emulator?tabs=windows#update-the-pointer-to-your-android-sdk

通过 NuGet 安装包。 Xamarin.Forms.DualScreenhttps://www.nuget.org/packages/Xamarin.Forms.DualScreen

使用如下所示的 xaml。

 <dualScreen:TwoPaneView>
    <dualScreen:TwoPaneView.Pane1>
        <StackLayout>
            <Label Text="Pane1 Content" />
        </StackLayout>
    </dualScreen:TwoPaneView.Pane1>
    <dualScreen:TwoPaneView.Pane2>
        <StackLayout>
            <Label Text="Pane2 Content" />
        </StackLayout>
    </dualScreen:TwoPaneView.Pane2>
</dualScreen:TwoPaneView>

使用模拟器 <build> (Android 10.0 – API 29) 运行项目

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。