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

一. 启动手机预装内置程序打开文件 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]   在浏览器中打开指定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 Reserved file and URI associations for Windows Phone 8

 

 



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章