HoloLens 2 App using LaunchUriAsync to open external apps

112 Views Asked by At

I would like to build functionality into my HoloLens 2 app to launch native headset apps locally. For example, I would like to be able to open and manipulate a PDF in a web browser, a photo in the photo viewer, or a 3D model in the 3D viewer while still having my app running in the same space.

Currently, any time I try to open a file using the headset's file browser while running my app, the file opens in its native external app (ex. PDF in browser, image in photo viewer, etc.), but when that happens, my app in the background freezes and its UI becomes stuck to my gaze rather than staying in world space and being interactable. The behavior returns to normal when I close out of the file browser/web browser/photo viewer. I would like to be able to have multiple of these windows open at the same time while still interacting with my app normally.

Unity Versions: 2021.3.23f1 Platform: Universal Windows Platform MRTK: 3.0 HoloLens 2 OS: Windows Holographic Operating System

I did some research and saw that (https://learn.microsoft.com/en-us/uwp/api/windows.system.launcher.launchuriasync?view=winrt-22621) states that an external app can be called via LaunchUriAsync and that it must be done on the UI thread. The Uri's for most HoloLens apps can be found here (https://learn.microsoft.com/en-us/windows/uwp/launch-resume/launch-default-app). I attempted it as seen in the attached image and tested it with multiple HoloLens app Uri's and my debugging shows it making it all the way to the await call inside the thread, but nothing happens from there. Both true and false were entered as the lambda's second parameter - both did nothing. Microsoft's documentation points to a set of Uri options that can be set using this reference to provide priority between the internal and external apps running, but Unity does not recognize the libraries that it uses (Microsoft.System), couldn't find a way to get it to compile in UWP. App thread execution was tested in all of the above cases as well, just for good measure - none worked.

This forum post seems to point to a different thread that should be used to do what I'm trying to. This was tried as well, produced the same results as the above did on the UI thread.

1

There are 1 best solutions below

3
Ying Li - MSFT On

There are two scenarios to consider.

In the first scenario, if “the new app” is also an immersive app, it’s important to note that the HoloLens operating system does not inherently support the simultaneous operation of multiple immersive apps. When you launch a new immersive app, all other active apps will immediately become inactive. This is by design.

In the second scenario, if “the new app” is a 2D view app, you can continue interacting with the previously opened immersive app. I conducted some tests using the Launcher.LaunchUri method, which confirmed that the interaction with the previous immersive app is not interrupted when you open a new 2D view app.