一. 启动手机预装内置程序打开文件file association
这里以打开word文档为例子
string fileToLaunch = @"HelloKitty.docx"; // Launch a .docx file that came with the package. private async void LaunchFileButton_Click(object sender, RoutedEventArgs e) { // First, get the word file from the package's doc directory. var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(fileToLaunch); // Next, launch the file. bool success = await Windows.System.Launcher.LaunchFileAsync(file); if (success) { } else { } }
二. 启动手机已安装第三方程序Protocol association
a. 首先定义一个遵守Protocol association协议的第三方程序
Protocol association需要在WPAppManifest.xaml注册;
要注册Protocol assocation,必须用XML (Text) Editor打开WPAppManifest.xaml;必须在</Token>后面添加类似如下代码:<Extensions> <Protocol Name="mkv" NavUriFragment="encodedLaunchUri=%s" TaskID="_default" /></Extensions>b. 启动支持mkv协议的第三方程序
Windows.System.Launcher.LaunchUriAsync(new Uri("mkv:HelloKitty"));
三 Windows Phone8系统保留的关联URI, 注意:关键词前的“ :”
bing:[keyword] 打开bing并按照关键词搜索
callto:dtmf:http:[url] 在浏览器中打开指定URLhttps:[url] 在浏览器中打开指定URLmaps:mailto:[Email] 打开邮件界面,给指定联系人发送邮件ms-excel: ms-powerpoint: ms-settings-accounts:ms-settings-airplanemode: 打开飞行模式设置开关ms-settings-bluetooth: 打开蓝牙设置开关ms-settings-cellular: 打开手机网络设置开关ms-settings-emailandaccounts: 打开电子邮件+账户设置开关ms-settings-location: 打开定位设置开关ms-settings-lock: 打开锁屏设置开关ms-settings-wifi: 打开wifi设置开关ms-word:office:onenote:tel:[phone number] 打开拨号界面呼叫电话,对于省略电话号码,如果当前处于通话中可以直接进入拨号界面.wallet:xbls:zune:navigate?appid=[app ID] 打开Windows Phone商店,并显示指定的应用程序的详细信息页面。zune:reviewapp zune:reviewapp?appid=[app ID] 打开Windows Phone商店,并显示指定的应用程序的打分并评论页面。zune:search?keyword=[search keyword]&publisher=[publisher name]&contenttype=app 打开Windows Phone商店,并按设定的关键词搜索应用程序。注意这里的所有的参数都是可选的,支持中英文关键词。
四:系统支持的内置文件类型 以及系统 保留类型参考 MSDN