Reputation: 21
I am trying to build a Xamarin Forms project for Surface Duo. The project runs, but will not utilize both screens. I followed the steps at Xamarin for Surface Duo - Dual-screen | Microsoft Docs:
Updated the pointer to the SDK.
Added Xamarin.Forms.DualScreen.DualScreenService.Init(this);
to mainactivity.cs
.
Modified the Activity abbribute to include: ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.UiMode
.
Included the Xamarin.DuoSdk package in the Android app.
While reading through the emulator output, one line recommended to turn off hyper-V using bcdedit command, which I did.
Selected <build>
(Android 10.0 – API 29)
I downloaded some of the samples (Sketch 360 and Dual Screen Demos) with no luck in getting them to use both screens. I ran the demos as posted on Get, and updated the packages, with no luck. I checked the phone settings in the emulator to see if there was a setting to enable both screens, but didn’t find anything. There are some errors, warnings in the emulator output, but not sure how to fix them.
Emulator Output
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, 327), size=(700x21), dirty=(700x21 0, 0) (A device attached to the system is not functioning.) ((null):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))
Build Output
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...
Upvotes: 1
Views: 233
Reputation: 682
If you are asking how to get the app to use both screens programmatically, rather than the user taking the action after starting the app, that can't be done.
See the explanations here: https://learn.microsoft.com/en-us/dual-screen/introduction
When the user launches an app, its core window opens maximized and occupies the full width and height of a single screen.
The user is responsible for spanning the app, it's not a state the app enters programmatically.
Users are always in control: In order to avoid unpredictable (or potentially destructive) experiences for your users, apps shouldn't automatically enter a spanned state without an intentional, user-initiated action. Let the user decide.
Upvotes: 2
Reputation: 10978
Run the Surface Duo Emulator for Visual Studio
to start the Surface Duo emulator. If you have any issue about the emulator, you could troubleshoot with the link below. https://learn.microsoft.com/en-us/dual-screen/xamarin/use-emulator?tabs=windows#update-the-pointer-to-your-android-sdk
Install the package via NuGet. Xamarin.Forms.DualScreen
:https://www.nuget.org/packages/Xamarin.Forms.DualScreen
Use the xaml like below.
<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>
Run the project with emulator <build> (Android 10.0 – API 29)
Upvotes: 0