slaphshot33324
slaphshot33324

Reputation: 658

How to access the 2nd screen in a dual screen Android phone with Xamarin

I'm starting to work on a project where we need to access the 2nd screen of a dual screen phone, we are using Xamarin. I cannot find any documentation on how to do this. Is anyone aware of a way to do this?

Upvotes: 1

Views: 408

Answers (1)

Conceptdev
Conceptdev

Reputation: 3261

The above comments are focused on second external screens, which is mostly what was around in 2019 :)

Now there are multiple dual-screen devices, including the Microsoft Surface Duo, and a couple of different styles from Samsung (Galaxy Fold/2, Galaxy Flip).

If you're using Xamarin.Forms, there's a TwoPaneView layout control that specifically detects and adapts to dual-screens, and also a DualScreenInfo helper class for device metrics. Get started docs and more details are available on learn.microsoft.com. Check out these samples and this GitHub repo. These APIs are currently hardcoded for the Surface Duo device.

If you're using Xamarin.Android, you have two options:

  • Microsoft's DisplayMask API, which is surfaced in the Xamarin.DuoSDK NuGet package. This is also targeted just at the Surface Duo - the GitHub repo has Xamarin.Android samples showing how it works.
  • The binding for Android's Jetpack Window Manager, in Xamarin.AndroidX.Window NuGet package (currently in alpha). This is the 'generic' API that will work on folding devices from multiple OEMs (eg. Samsung). Because it's still in alpha (as of April 2021), there aren't a lot of samples around but better support is coming.

Upvotes: 1

Related Questions