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

来源:互联网 发布:吾生有涯而知无涯解析 编辑:程序博客网 时间:2024/04/29 19:50
一. 启动手机预装内置程序打开文件file association

这里以打开word文档为例子

[csharp] view plaincopy
  1. string fileToLaunch = @"HelloKitty.docx";  
  2.   
  3.        // Launch a .docx file that came with the package.  
  4.        private async void LaunchFileButton_Click(object sender, RoutedEventArgs e)  
  5.        {  
  6.            // First, get the word file from the package's doc directory.  
  7.            IStorageFolder applicationFolder = ApplicationData.Current.LocalFolder;

               IStorageFile storageFile = await applicationFolder.GetFileAsync(fileToLaunch);
  8.   
  9.            // Next, launch the file.  
  10.            bool success = await Windows.System.Launcher.LaunchFileAsync(file);  
  11.            if (success)  
  12.            {  
  13.                  
  14.            }  
  15.            else  
  16.            {  
  17.                  
  18.            }  
  19.        }  

二. 启动手机已安装第三方程序 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
  1. bing:[keyword]   打开bing并按照关键词搜索  
  2. callto:  
  3. dtmf:  
  4. http:[url]   在浏览器中打开指定URL  
  5. https:[url]   在浏览器中打开指定URL  
  6. maps:  
  7. mailto:[Email]   打开邮件界面,给指定联系人发送邮件  
  8. ms-excel:    
  9. ms-powerpoint:    
  10. ms-settings-accounts:  
  11. ms-settings-airplanemode: 打开飞行模式设置开关  
  12. ms-settings-bluetooth: 打开蓝牙设置开关  
  13. ms-settings-cellular: 打开手机网络设置开关  
  14. ms-settings-emailandaccounts: 打开电子邮件+账户设置开关  
  15. ms-settings-location: 打开定位设置开关  
  16. ms-settings-lock: 打开锁屏设置开关  
  17. ms-settings-wifi: 打开wifi设置开关  
  18. ms-word:  
  19. office:  
  20. onenote:  
  21. tel:[phone number] 打开拨号界面呼叫电话,对于省略电话号码,如果当前处于通话中可以直接进入拨号界面.  
  22. wallet:  
  23. xbls:  
  24. zune:navigate?appid=[app ID] 打开Windows Phone商店,并显示指定的应用程序的详细信息页面。  
  25. zune:reviewapp   
  26. zune:reviewapp?appid=[app ID] 打开Windows Phone商店,并显示指定的应用程序的打分并评论页面。  
  27. zune:search?keyword=[search keyword]&publisher=[publisher name]&contenttype=app   
  28. 打开Windows Phone商店,并按设定的关键词搜索应用程序。注意这里的所有的参数都是可选的,支持中英文关键词。  



 四:系统支持的内置文件类型 以及系统 保留类型参考 MSDN Reserved file and URI associations for Windows Phone 8

 

 http://blog.csdn.net/flashtao613/article/details/8085759

原创粉丝点击