Windows Phone 8.1 : how to Launch an Installed app From My app

后端 未结 2 505
离开以前
离开以前 2021-01-27 15:59

I have tried the following links

How do I launch other app from my own app in Windows Phone 8.1?

Call an external app on windows phone 8.1 runtime(not silverlig

相关标签:
2条回答
  • 2021-01-27 16:21

    It works for me.

    1. setup your app which launch from other.

      add this in WMAppManifest.xaml between < /token> and < ScreenResolutions>

      <Extensions>
         <Protocol Name="alsdkcs" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" />
      </Extensions>
      

      add a class "AssociationUriMapper " and override the function "MapUri()"

      class AssociationUriMapper : UriMapperBase{
         private string tempUri;
      
         public override Uri MapUri(Uri uri){
            tempUri = System.Net.HttpUtility.UrlDecode(uri.ToString());
            if (tempUri.Contains("alsdkcs:MainPage?id=")){
               int idIndex = tempUri.IndexOf("id=") + 3; //3 is the length of "id="           
               string id = tempUri.Substring(idIndex);
      
               return new Uri("/MainPage.xaml?id=" + id, UriKind.Relative);
           }
           return uri;
        }
      }
      

      and call them from other app.xaml.cs at this section of InitializePhoneApplication() function

      RootFrame.UriMapper = new AssociationUriMapper(); // add this line only between RootFrame.Navigated += CompleteInitializePhoneApplication; and RootFrame.NavigationFailed += RootFrame_NavigationFailed;
      
    2. finally call fron other app to launch an app

      var success = await Windows.System.Launcher.LaunchUriAsync(new System.Uri("alsdkcs:MainPage?id="+5)); 
      if (success){
         // URI launched
      }
      else{
        // URI launch failed
      }
      

      where "alsdkcs" is protocol name.

    more details see msdn

    0 讨论(0)
  • 2021-01-27 16:38

    If the app has a registered URI, then you should be able to use Launcher.LaunchUriAsync for this. You can also find some help, here at MSDN - How to launch the default app for a URI.

    Otherwise I don't think it's possible.

    0 讨论(0)
提交回复
热议问题