簡體   English   中英

Windows Phone 8.1:如何從我的應用程序啟動已安裝的應用程序

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

我嘗試了以下鏈接

如何從Windows Phone 8.1中自己的應用程序啟動其他應用程序?

在Windows Phone 8.1運行時上調用外部應用程序(非Silverlight)XAML C#應用程序

但對我沒有任何幫助,因為我只是想通過單擊按鈕從我的應用程序啟動一個應用程序,例如憤怒的小鳥。

請幫忙

如果應用程序具有已注冊的URI ,那么您應該可以為此使用Launcher.LaunchUriAsync 您還可以在MSDN上找到一些幫助-如何啟動URI的默認應用程序

否則,我認為這是不可能的。

這個對我有用。

  1. 設置從其他啟動的應用程序。

    在</ token>和<ScreenResolutions>之間的WMAppManifest.xaml中添加它

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

    添加一個類“ 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. 最終調用fron其他應用程序以啟動一個應用程序

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

    其中“ alsdkcs”是協議名稱。

詳細信息請參見msdn

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM