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

 

 



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