Hello!

It is time to begin to share some experiences developing for Hololens. This postĀ is related to UWP Apps, general base for all devices in Windows 10 family.

While have a base common of features in all the devices, for some featuresĀ is a good practice toĀ validate if the functionalities are implemented or not in eachĀ type of device.

As well, according to the article [Dynamically detecting features with API contracts (10 by 10)], the right way to do this is using the ApiInformation class. The example shared bu the Windows Dev Center team is very easy to read and understand:

using Windows.Foundation.Metadata;

if (ApiInformation.IsTypePresent(“Windows.Media.Playlists.Playlist”))
{
await myAwesomePlaylist.SaveAsAsync( … );
}

The code is self explanatory, if we can use the APIs of Playlist, we have everything ready to go on. In the Hololens scenario, this works very well. Some featuresĀ likeĀ Print or Share, that are not directly available on the platform.
However, we must be careful here. In example: What happens if we want to access the camera from the Hololens and use the CameraCaptureUI class? This class we haveĀ an option to see in time real the feed of the camera and take a photo on this.

Note: I know is an inconsistency to use this in the Hololens. Camera will always show what they are seeing. However as an example for the post it comes great!

So, ifĀ we use CameraCaptureUIĀ we’ll have the following stepsĀ in Hololens:

  • The API CameraCaptureUI will be returned asĀ available inĀ Hololens
  • When we use it, Windows 10 will suggests us to download an app from the Store for this
  • What?

Here is a live sample:

2016 08 23 Hololens CameraCaptureUi

Using this sample code:

Clipboard02

So, for this scenario, validate the availability of an API is not working. Here comes the time of go for an ungly solution

Use AnalyticsInfo.VersionInfo.DeviceFamily to see the type of device where the app is running. In the case of the Hololens this property returns “Windows.Holographic”.

This solution works. And I know, I add a BIG NOTE: As soon as UWP has a better way to validate this type of scenarios, this feature and evidence must be eliminated!

Clipboard06

A kitten and 2 unicorns less thanks to 5 lines of code! Sorry about that 😦

GreetingsĀ @ Toronto

El Bruno

References

Leave a comment

Discover more from El Bruno

Subscribe now to keep reading and get access to the full archive.

Continue reading