Windows Phone 7 使用启动器(Lanucher)
Launcher启动器:启动Windows Phone 7内置应用程序。启动器只是负责把相应的应用程序启动起来就可以了。
Lanucher 在使用时跟Chooser 相同,必须要注意应用程式生命周期;而Lanucher 主要的功能是呼叫Windows Phone 7 中其他的功能;例如说拨打电话、WebBrowser 等功能,使用Lanucher 时同样的,必须要引入Microsoft .Phone.Tasks 的命名空间,下面笔者列出Lanucher 的各项功能
包括以下几个:
EmailComposeTask: 启动发送Email的应用程序。
MediaPlayerLauncher: 启动MeidaPlayer应用程序。
PhoneCallTask: 启动打电话应用程序。
SearchTask: 启动搜索应用程序。
SmsComposeTask: 启动发短信应用程序。
WebBrowserTask: 启动IE。
MarketplaceDetailTask: 启动Marketplace客户端应用程序,并显示指定应用的详细信息。
MarketplaceHubTask: 启动Marketplace客户端应用程序。
MarketplaceReviewTask: 启动Marketplace客户端应用程序的审查页面。
MarketplaceSearchTask: 启动Marketplace客户端应用程序的搜索页面。
1、EmailComposeTask
EmailComposeTask 让您可以呼叫出系统预设的寄送Email 功能,并且在呼叫之前,能够设定收件人,邮件内容等讯息,例如笔者做了以下的介面,执行的时候会出现像右图这样的错误讯息,这是因为内建的开发用模拟器没有设定email 相关的帐号,因此无法做寄送email 的动作;不过不要紧,等有了实机之后就可以将应用程式部属到机器上做实际的测试的
而程式码的部分也是相当的简单,例如下面这样子
EmailComposeTask ect = new EmailComposeTask();ect.To = txtEmailAddress.Text;ect.Subject = txtSubject.Text;ect.Body = txtMailBody.Text;ect.Show();
- View Code <!--LayoutRoot is the root grid where all page content is placed-->
- <Grid x:Name="LayoutRoot" Background="Transparent">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
- <!--TitlePanel contains the name of the application and page title-->
- <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
- <TextBlock x:Name="ApplicationTitle" Text="Lanucher Demo" Style="{StaticResource PhoneTextNormalStyle}"/>
- <TextBlock x:Name="PageTitle" Text="EmailCompose" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
- </StackPanel>
- <ScrollViewer Grid.Row="1">
- <StackPanel x:Name="ContentPanel" >
- <TextBlock Margin="3,1,1,1" Height="33" x:Name="textBlock1" Text="收件人郵件地址" />
- <TextBox x:Name="txtEmailAddress" Height="69" TextWrapping="Wrap" Text="TextBox" />
- <TextBlock Margin="3,1,1,1" Height="33" Name="textBlock2" Text="郵件主旨" />
- <TextBox Height="69" Name="txtSubject" Text="TextBox" TextWrapping="Wrap"/>
- <TextBlock Margin="3,1,1,1" Height="33" Name="textBlock3" Text="郵件內容" />
- <TextBox Height="274" Name="txtMailBody" Text="TextBox" TextWrapping="Wrap" />
- </StackPanel>
- </ScrollViewer>
- <!--ContentPanel - place additional content here-->
- </Grid>
- <!--Sample code showing usage of ApplicationBar-->
- <phone:PhoneApplicationPage.ApplicationBar>
- <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
- <shell:ApplicationBarIconButton IconUri="/Images/appbar.check.rest.png" Text="OK" x:Name="btnOK" Click="btnOK_Click" />
- <shell:ApplicationBarIconButton IconUri="/Images/appbar.cancel.rest.png" Text="Cancel" x:Name="btnCancel" />
- </shell:ApplicationBar>
- </phone:PhoneApplicationPage.ApplicationBar>
- View Code using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using Microsoft.Phone.Controls;
- using Microsoft.Phone.Tasks;
- namespace LanucherDemo
- {
- public partial class EmailCompose : PhoneApplicationPage
- {
- public EmailCompose()
- {
- InitializeComponent();
- txtEmailAddress.InputScope = new InputScope
- {
- Names = {new InputScopeName() { NameValue = InputScopeNameValue.EmailNameOrAddress }}
- };
- }
- private void btnOK_Click(object sender, EventArgs e)
- {
- EmailComposeTask ect = new EmailComposeTask();
- ect.To = txtEmailAddress.Text;
- ect.Subject = txtSubject.Text;
- ect.Body = txtMailBody.Text;
- ect.Show();
- }
- }
- }
Windows Phone 7 使用启动器(Lanucher)
Launcher启动器:启动Windows Phone 7内置应用程序。启动器只是负责把相应的应用程序启动起来就可以了。
Lanucher 在使用时跟Chooser 相同,必须要注意应用程式生命周期;而Lanucher 主要的功能是呼叫Windows Phone 7 中其他的功能;例如说拨打电话、WebBrowser 等功能,使用Lanucher 时同样的,必须要引入Microsoft .Phone.Tasks 的命名空间,下面笔者列出Lanucher 的各项功能
包括以下几个:
EmailComposeTask: 启动发送Email的应用程序。
MediaPlayerLauncher: 启动MeidaPlayer应用程序。
PhoneCallTask: 启动打电话应用程序。
SearchTask: 启动搜索应用程序。
SmsComposeTask: 启动发短信应用程序。
WebBrowserTask: 启动IE。
MarketplaceDetailTask: 启动Marketplace客户端应用程序,并显示指定应用的详细信息。
MarketplaceHubTask: 启动Marketplace客户端应用程序。
MarketplaceReviewTask: 启动Marketplace客户端应用程序的审查页面。
MarketplaceSearchTask: 启动Marketplace客户端应用程序的搜索页面。
1、EmailComposeTask
EmailComposeTask 让您可以呼叫出系统预设的寄送Email 功能,并且在呼叫之前,能够设定收件人,邮件内容等讯息,例如笔者做了以下的介面,执行的时候会出现像右图这样的错误讯息,这是因为内建的开发用模拟器没有设定email 相关的帐号,因此无法做寄送email 的动作;不过不要紧,等有了实机之后就可以将应用程式部属到机器上做实际的测试的
而程式码的部分也是相当的简单,例如下面这样子
EmailComposeTask ect = new EmailComposeTask();ect.To = txtEmailAddress.Text;ect.Subject = txtSubject.Text;ect.Body = txtMailBody.Text;ect.Show();
按 Ctrl+C 复制代码
按 Ctrl+C 复制代码
按 Ctrl+C 复制代码
按 Ctrl+C 复制代码
2、PhoneCallTask
PhoneCallTask 是能够让您在应用程式中去执行拨打电话的功能,先来看看执行效果
执行PhoneCallTask 时,需要先指定电话号码以及显示在画面上的名称(DisplayName),之后呼叫Show 的方法;呼叫Show 方法之后,首先会请使用者确认是否要拨打电话(中间的画面),之后便会进行拨打电话的动作了;而程式码的部分也相当的简单,大致会像下面这样
PhoneCallTask pct = new PhoneCallTask();pct.DisplayName = "Test Call";pct.PhoneNumber = txtPhoneNo.Text;pct.Show();
- View Code <!--LayoutRoot is the root grid where all page content is placed-->
- <Grid x:Name="LayoutRoot" Background="Transparent">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
- <!--TitlePanel contains the name of the application and page title-->
- <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
- <TextBlock x:Name="ApplicationTitle" Text="Lanucher Demo" Style="{StaticResource PhoneTextNormalStyle}"/>
- <TextBlock x:Name="PageTitle" Text="Phone Call" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
- </StackPanel>
- <StackPanel x:Name="ContentPanel" Margin="12,0,12,0" Grid.Row="1" >
- <TextBlock Height="35" Margin="8,0" TextWrapping="Wrap" Text="電話號碼"/>
- <TextBox x:Name="txtPhoneNo" Height="72" Margin="8,0" TextWrapping="Wrap" Text=""/>
- <Button Content="Make call" Height="80" Margin="196,0,27,0" Click="Button_Click" />
- </StackPanel>
- <!--ContentPanel - place additional content here-->
- </Grid>
- View Code using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using Microsoft.Phone.Controls;
- using Microsoft.Phone.Tasks;
- namespace LanucherDemo
- {
- public partial class PhoneCall : PhoneApplicationPage
- {
- public PhoneCall()
- {
- InitializeComponent();
- txtPhoneNo.InputScope = new InputScope
- {
- Names = { new InputScopeName { NameValue = InputScopeNameValue.TelephoneNumber } }
- };
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- PhoneCallTask pct = new PhoneCallTask();
- pct.DisplayName = "Test Call";
- pct.PhoneNumber = txtPhoneNo.Text;
- pct.Show();
- }
- }
- }
3、SerachTask
SearchTask 能够让应用程式指定查询的关键字,并且去启动系统预设的查询功能;先来看看执行的效果
当您第一次去启动SearchTask 时,您可能会看到中间的画面,这是询问使用者,是不是允许装置利用GPS/AGPS 等方式去取得目前所在位置的一些相关资讯,确认之后就最出现最右边的收寻结果画面
SearchTask st = new SearchTask();st.SearchQuery = txtKeyword.Text;st.Show();
4、SmscomposeTask
SmscomposeTask 让应用程式可以呼叫系统的简讯发送功能,先来看看执行的效果
使用的方式跟EmailComposeTask 相当的相似,只要设定接收端的号码以及SMS 内容之后,就可以启动系统预设的简讯发送介面了。程式码的部分大致会像下面这样
SmsComposeTask sct = new SmsComposeTask();
sct.To = txtPhoneNo.Text;
sct.Body = txtMessage.Text;
sct.Show();
4、WebBrowserTask
WebBrowserTask 是启动难建浏览器的功能,并且前往您指定的位置,下面先来看一下执行之后的效果
像上图的样子,笔者是将WebBrowserTask 的URL 属性设定为msdn.microsoft.com,在呼叫Show 的方法之后便会前往指定的页面,程式码大概会像下面这样子
WebBrowserTask wbt = new WebBrowserTask();wbt.URL = txtUrl.Text;wbt.Show();
5、 MediaPlayerLanucher
MediaPlayerLanucher 顾名思义就是去启动MediaPlayer,而其中有几个属性要特别注意
- Location
Location 是描述档案是放置在『什么样的位置』,在VS 环境中可以设定成下面三种
MediaLocationType.Install:『Install』指的就是跟着你的xap 档案一起部属过去的相关档案,也就是位于安装的目录中。
MediaLocationType.Data:『Data』指的是位于隔离储存区当中的档案,也就是说如果您的档案是执行之后才会取得或是产生的(例如说从网路下载),而会将档案写入到隔离储存区当中,这个时候就要设定为这个属性。
MediaLocationType.None:『None』的属性目前来说是没有作用的,如果设定为None,那么呼叫Show 的方法之后,直接就会丢出『FileNotFroundException』。
- Meida
Media 是档案的位置以及档案名称,是以Uri 的方式来表示,例如
mpl.Media = new Uri(@"Media\test.wmv", UriKind.Relative);
- Controls
Controls 是设定MediaPlayer 出现之后,在画面上会出现哪一些控制按钮;而各个项目也可以利用OR 的方式去设定,例如说设定的方式可能会下面这样
//设定所有控制纽都出现
mpl.Controls = MediaPlaybackControls.All;
//设定出现停止按钮以及暂停按钮
mpl.Controls = MediaPlaybackControls.Pause | MediaPlaybackControls.Stop;
接下来来看一下执行的效果,首先笔者建立了一个简单的测试影片test.wmv,请特别注意,在Build Action 的部分要设定成Content,copy to output directory 要设定成『copy if newer』或是『always copy』
介面的部分相当简单,只有一个拨放的按钮,点击之后就会进行拨放的动作(您如果在拨放的过程没有看到画面的话,请用滑鼠点击模拟器的画面);接下来来看看程式码的部分
MediaPlayerLauncher mpl = new MediaPlayerLauncher();
//指定档案放置的位置属性
mpl.Location = MediaLocationType.Install;
//设定所有控制纽都出现
mpl.Controls = MediaPlaybackControls.All;
//设定出现停止按钮以及暂停按钮
//mpl.Controls = MediaPlaybackControls.Pause | MediaPlaybackControls.Stop;
//指定播放的档案
mpl.Media = new Uri(@"Media\test.wmv", UriKind.Relative);
mpl.Show(); MarketPlaceDetailTask
6、MarketPlaceDetailTask
MarketPlaceDetailTask 主要的动作会启动系统内建的MarketPlace 应用程式,并且可以指定要浏览的应用程式ID;主要要特别注意两个属性;第一个是ContentType 的属性,目前来说ContentType 一定要指定为Applications,如果指定为Music 的话,在呼叫Show 的方法时就会直接丢出错误了。而另一个是ContentIdentifier,这个属性是要指定应用程式ID (
在短暂的搜寻动作之后换出现像是右图的结果,这是因为目前在MarketPlace 上面找不到指定的应用程式的关系;相关动作的程式码大致会像是下面这样
MarketplaceDetailTask mdt = new MarketplaceDetailTask();
//只能设定为Applcations
mdt.ContentType = MarketplaceContentType.Applications;
//当没有指定值则会以目前的应用程式为目标
//如果格式检查不符合GUID 的格式则会丢出exception
mdt.ContentIdentifier = txtID.Text;
mdt.Show();
7、MarketplaceHubTask
MarketlaceHubTask 主要的功用是启动后便会带领使用者直接连线到Marketplace;操作的方法与其他Lanucher 类似,也是相当的简单,要注意的是ContentType 属性,可以设定为Application 与Music;下面就来看看执行的效果
中间画面是当ContentType 设定为Music 时的画面,最右边则是设定为Application 时;您看到的画面因为时间不同有可能跟笔者的是不相同的,各位可以自行实做看看;程式码的部分也简单的列出在下面
MarketplaceHubTask mht = new MarketplaceHubTask();
mht.ContentType = MarketplaceContentType.Applications;
//mht.ContentType = MarketplaceContentType.Music;
mht.Show();
8、 MarketplaceReviewTask
MarketplcaeReviewTask 的用途是在启动之后会连到Marketplace 的页面,并直接的为您的应用程式做评分、建议等地动作;使用方式相当的简单,只要利用下列的程式码就可以了
MarketplaceReviewTask mrt = new MarketplaceReviewTask();
9、 MarketPlaceSearchTask
MarketplaceSearchTask 可以让您搜寻Marketplace 上的应用程式或是音乐(一样是透过ContentType 的属性来设定),另外SearchTerms 可以指定关键字,例如说输入sms 会得到类似下面的效果
- View Code
- <!--LayoutRoot is the root grid where all page content is placed-->
- <Grid x:Name="LayoutRoot" Background="Transparent">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
- <!--TitlePanel contains the name of the application and page title-->
- <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
- <TextBlock x:Name="ApplicationTitle" Text="Lanucher Demo" Style="{StaticResource PhoneTextNormalStyle}"/>
- <TextBlock x:Name="PageTitle" Text="MarketPlace" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
- </StackPanel>
- <StackPanel x:Name="ContentPanel" Margin="12,0,12,0" Grid.Row="1" >
- <TextBlock Height="28" Margin="8,0" TextWrapping="Wrap" Text="應用程式 ID"/>
- <TextBox x:Name="txtID" Height="66" Margin="8,0" TextWrapping="Wrap" Text="cbd00900-0600-11db-89ca-0019b92a3933"/>
- <Button Content="Show Detail" Height="76" Margin="8,0,8,0" Click="Button_Click" Width="410" />
- <Button Content="MarketplaceHub" Height="80" Name="button1" Width="409" Click="button1_Click" />
- <Button Content="Application Review" Height="79" Name="button2" Width="409" Click="button2_Click" />
- <TextBlock Height="28" Text="搜尋關鍵字" TextWrapping="Wrap" />
- <TextBox Height="66" Name="txtSearchTerms" Text="sms" TextWrapping="Wrap" />
- <Button Content="Search Marketplace" Height="79" Name="button3" Width="409" Click="button3_Click" />
- </StackPanel>
- <!--ContentPanel - place additional content here-->
- </Grid>
- View Code
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Animation;
- using System.Windows.Shapes;
- using Microsoft.Phone.Controls;
- using Microsoft.Phone.Tasks;
- namespace LanucherDemo
- {
- public partial class MarketPlaceDetail : PhoneApplicationPage
- {
- public MarketPlaceDetail()
- {
- InitializeComponent();
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- MarketplaceDetailTask mdt = new MarketplaceDetailTask();
- //只能設定為Applcation
- mdt.ContentType = MarketplaceContentType.Applications;
- //當沒有指定值則會以目前的應用程式為目標
- //如果格式檢查不符合GUID的格式則會丟出exception
- mdt.ContentIdentifier = txtID.Text;
- mdt.Show();
- }
- private void button1_Click(object sender, RoutedEventArgs e)
- {
- MarketplaceHubTask mht = new MarketplaceHubTask();
- mht.ContentType = MarketplaceContentType.Applications;
- //mht.ContentType = MarketplaceContentType.Music;
- mht.Show();
- }
- private void button2_Click(object sender, RoutedEventArgs e)
- {
- MarketplaceReviewTask mrt = new MarketplaceReviewTask();
- mrt.Show();
- }
- private void button3_Click(object sender, RoutedEventArgs e)
- {
- MarketplaceSearchTask mst = new MarketplaceSearchTask();
- //mst.ContentType = MarketplaceContentType.Music;
- mst.ContentType = MarketplaceContentType.Applications;
- mst.SearchTerms = txtSearchTerms.Text;
- mst.Show();
- }
- }
- }
本文转自linzheng 51CTO博客,原文链接:http://blog.51cto.com/linzheng/1079183
Windows Phone 7 使用启动器(Lanucher)相关推荐
- Windows Phone 7的启动器和选择器
启动器和选择器是Windows Phone向开发者提供的两组API,使应用程序能方便地调用API完成手机内置的一些常规任务,例如打电话,发电子邮件和拍照片. 在Windows Phone操作系统中,所 ...
- 如何在Windows Server 2016上配置iSCSI启动器
In this article, I am going to explain how we can configure the iSCSI initiator and use it to connec ...
- 配置iscsi服务器_在Windows Server 2016上安装和配置iSCSI目标服务器
配置iscsi服务器 In this article, I am going to explain how we can install and configure the iSCSI Target ...
- java启动器_打造java启动器步骤三
一.Java程序的启动过程 对于普通用户来说,Java让人不习惯的是程序的启动过程:即使对于富有经验的开发者,为了用默认的装载器启动Java程序,不得不编写大量批命令.脚本文件,不得不在命令行环境下进 ...
- Ubuntu下制作windows U盘启动盘
转载自http://blog.csdn.net/lym152898/article/details/72858617 需要工具: 1. GParted:Ubuntu下一款非常好用的图形硬盘分区格式化 ...
- linux下制作windows u盘启动盘,Ubuntu下制作windows U盘启动盘
最近想给装有Ubuntu和win7的笔记本中的win7生成win10.不曾想将win7的启动引导区给覆盖掉了,只能启动Ubuntu了.于是就想在Ubuntu下制作windows的U盘启动盘重新安装wi ...
- 【Linux】Ubuntu下制作windows U盘启动盘
转载自:http://blog.csdn.net/lym152898/article/details/72858617 最近想给装有Ubuntu和win7的笔记本中的win7生成win10.不曾想将w ...
- linux玩我的世界java版_Linux下安装我的世界(Minecraft)
今天下午突然心血来潮想玩我的世界(Minecraft),但想想现在是Linux系统.我查阅了网上大部分的教程,都差不多过期了,正准备放弃的时候突然想起来Minecraft是Java写的啊!肯定支持Li ...
- [python]_ELVE_pip2和pip3如何共存
作者:匿名用户 链接:https://www.zhihu.com/question/21653286/answer/95532074 来源:知乎 著作权归作者所有,转载请联系作者获得授权. 想学习Py ...
最新文章
- Spring Cloud Alibaba 学无止境:下一代微服务架构的规划与展望
- 如何在 Azure 中的 Linux 经典虚拟机上设置终结点
- Java基础篇:String、StringBuffer、StringBuilder
- CF1066F Yet another 2D Walking
- 9.停下来说说jquery
- dlopen失败一例:路径字串多一个回车,导致文件找不到
- xshell5 Xshell6 商业版的破解版
- IAR MCS-51 v7.51A 软件注册机下载
- 北邮 复习 软件工程_【真题回忆】2018北邮软件工程专业课真题回忆版
- kmeans算法及python实现
- 《月亮与六便士》的读后感作文3000字
- macbook 安装win7
- Java学习笔记day18-红黑树-Map
- PS使得画布大小迅速和图像大小保持一致,裁切功能
- spring.jpa.hibernate.naming.physical-strategy
- 华为AC+AP上线配置
- linux的中文意思,Linux中的./!$是什么意思?
- Android自定义View(七)_Canvas之图片文字
- 力学笃行系列之Spring和JDK设计中用到的设计模式
- 80C51常用头文件
热门文章
- 微信小程序下拉框插件_微信小程序自定义select下拉选项框组件的实现代码_清玖_前端开发者...
- vue 图片复制黏贴上传_# quill-image-extend-module :完成vue-quill-editor图片上传,复制粘贴,拖拽...
- php文本域输出_如何在文本分类任务中Fine-Tune BERT
- 前端如何查看音频的长度_Android音频可视化
- mysql mha配置idrac远程关机_iDRAC远程管理功能试用_戴尔 PowerEdge R810(Xeon E7520/16GB/3*146GB)_服务器评测与技术-中关村在线...
- oracle写转帐的存储过程,Oracle存储过程及块编程基础经典案例
- c语言生成一个大素数,for语句计算输出10000以内最大素数怎么搞最简单??各位大神们...
- 7.Java 面试题整理(EJB 方面)
- 大数据学习笔记22:MR案例——双MR统计总利润并排序
- flash人物原地走路,Flash制作小人走路简单动画图文教程