How can I launch / switch a front-end application on Windows 10 IoT

I want to create a “Launcher application” to run on my Windows 10 IoT (Raspberry Pi 3) build 14986 (or later). A launcher application should simply have two buttons to launch (or switch) other applications already deployed on the device. I am wondering if anyone knows how to run an application (from C #)?

I looked at the API Windows.System.Launcher.LaunchUriAsync, but I'm not sure what to get through (I tested with some URIs and TargetApplicationPackageFamilyNameunder parameters, no luck (nothing happens when the method is called).

Example (which does not work):

    private void button_Click(object sender, RoutedEventArgs e)
    {
        Task.Run(async () =>
        {
            var options = new LauncherOptions();
            options.TargetApplicationPackageFamilyName = "27ad8aa6-8c23-48bd-9633-e331740e6ba7_mr3ez18jctte6!App";

            var uri = new Uri("about:blank");

            await Windows.System.Launcher.LaunchUriAsync(uri, options);
        });
    }
+4
source share
1 answer

Microsoft Code. :

https://code.msdn.microsoft.com/windowsapps/How-to-launch-an-UWP-app-5abfa878

:

private async void RunMainPage_Click(object sender, RoutedEventArgs e) 
{ 
    await LaunchAppAsync("test-launchmainpage://HostMainpage/Path1?param=This is param"); 
} 

private async void RunPage1_Click(object sender, RoutedEventArgs e) 
{ 
    await LaunchAppAsync("test-launchpage1://Page1/Path1?param1=This is param1&param1=This is param2"); 
} 

private async Task LaunchAppAsync(string uriStr) 
{ 
    Uri uri = new Uri(uriStr); 
    var promptOptions = new Windows.System.LauncherOptions(); 
    promptOptions.TreatAsUntrusted = false; 

    bool isSuccess = await Windows.System.Launcher.LaunchUriAsync(uri, promptOptions); 

    if (!isSuccess) 
    { 
        string msg = "Launch failed"; 
        await new MessageDialog(msg).ShowAsync(); 
    } 
}

, Windows Protocol , , URI LaunchApp.

+3

Source: https://habr.com/ru/post/1668599/


All Articles