3

I want to create an app that calls the Hololens default browser. I used the following code, but whenever I call this function, the Application will crash. If this code is not suitable for UWP, how can I call HoloLens' default browser in an app?

The version of the software I am using is:

1.Unity 2018 3.11f

2.Mixed Reality Toolkit v2.0.0 RC1

3.Visual Studio 2017

public void OpenAnlagenWiKi_URL()
{
    string tempUrl = string.Format("{0}", AnlagenWiKi_Link.text);
    Application.OpenURL(tempUrl);
}

I hope to successfully call HoloLens' default browser in the app.

  • "the application will crash", what does the exception say? And have you read the [documentation](https://docs.unity3d.com/ScriptReference/Application.OpenURL.html)? – Fredrik Schön May 08 '19 at 12:05
  • 2
    According to [this](https://stackoverflow.com/questions/42877493/call-microsoft-edge-inside-hololens-app) you cannot Application.OpenURL() in HoloLens because it will close down the application and THEN try to open the URL. – Fredrik Schön May 08 '19 at 12:09
  • @FredrikSchön thanks for your help ! I will try the method in the link you gave. – Kefei Zhang May 08 '19 at 12:52
  • there is no In-App-Browser...you have to minimize your app to open the browser – Perazim May 08 '19 at 13:28
  • @Perazim I want to use this code app to call an external browser, but each time it is used, it will directly cause the app to crash. Is there any other way? – Kefei Zhang May 09 '19 at 10:00
  • Try Application.Quit() in InApplicationFocus or OnApplicationPause, some ppl say it minimizes the app. But I dont know how to open the browser after you minimized your app :D Maybe you can use cortana and open via her the browser with a specific url – Perazim May 09 '19 at 12:29

1 Answers1

2

It's a bit tricky. Any Hololens application is actually UWP process.

First of all, you need to switch it into the background mode by calling AppResourceGroupInfo.StartSuspendAsync. The details are here.

When the app would go into background, you should call open process

System.Diagnostics.Process.Start("http://google.com");
Tania Chistyakova
  • 3,928
  • 6
  • 13