您的位置:首页 > 其它

windows phone 8 新增功能:从一个应用程序启动另一个程序(file association 和 Protocol association两种方式)

2013-03-25 16:21 429 查看
一. 启动手机预装内置程序打开文件
file association

这里以打开word文档为例子

[csharp] view
plaincopy

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.  

           IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder;

           IStorageFile storageFile = await applicationFolder.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,  注意:关键词前的“ :”

[plain] view
plaincopy

bing:[keyword]   打开bing并按照关键词搜索  

callto:  

dtmf:  

http:Reserved file and URI associations for Windows Phone 8" target=_blank>   在浏览器中打开指定URL  

https:[url]   在浏览器中打开指定URL  

maps:  

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 [url=http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207065(v=vs.105).aspx]Reserved file and URI associations for Windows Phone 8


 

 [url=http://blog.csdn.net/flashtao613/article/details/8085759]http://blog.csdn.net/flashtao613/article/details/8085759
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐