Windows Phone 8.1:如何从我的应用启动已安装的应用

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

我试过以下链接

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 silverlight) xaml c# application

但对我来说没有任何用处,因为我只是想启动一个应用程序,例如单击按钮从我的应用程序中获取愤怒的小鸟。

请帮忙

如果应用有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.

不然我觉得不可能

对我有用。

  1. 设置从其他应用程序启动的应用程序。

    在 < /token> 和 之间的 WMAppManifest.xaml 中添加这个

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

    添加一个 class "AssociationUriMapper " 并覆盖函数 "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;
      }
    }
    

    并在 InitializePhoneApplication() 函数的这一部分从其他 app.xaml.cs 调用它们

    RootFrame.UriMapper = new AssociationUriMapper(); // add this line only between RootFrame.Navigated += CompleteInitializePhoneApplication; and RootFrame.NavigationFailed += RootFrame_NavigationFailed;
    
  2. 终于从其他应用程序调用以启动应用程序

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

    其中 "alsdkcs" 是协议名称。

更多详情见msdn