Windows Store apps开发[46]当用户点击Toast通知时,我们可以做些什么
来源:互联网 发布:东华大学网络教育 编辑:程序博客网 时间:2024/04/27 16:26
注:本文由BeyondVincent(破船)原创首发
转载请注明出处:BeyondVincent(破船)@DevDiv.com
更多内容请查看下面的帖子
[DevDiv原创]Windows 8 开发Step by Step
小引
在之前的博文中,我曾对Toast通知进行了介绍,如下链接,建议不清楚Toast通知的可以去看看
Windows Store apps[9]通知概述(Toast,Tile和Badge)
Windows Store apps开发[10]通知使用(Toast,Tile和Badge)
在这篇文章中,我将对Toast通知进行深入的介绍:如何让Toast通知携带参数,并且在程序中如何获取Toast通知的携带的参数。
这个主题在有些时候非常有用:当用户点击Toast通知时,根据Toast通知的内容,直接使程序打开某个特定的画面。
Toast通知的数据走向步骤
我们先来看看Toast通知的数据走向步骤
1、程序或者web service创建并发送一个包含launch字符串的toast通知
2、toast通知到达
3、用户选择toast通知(单击或者触摸)
4、OnLaunched事件被触发
5、在程序的OnLaunched处理函数中读取launch字符串
6、程序根据launch字符串做出响应的处理(打开指定画面、进行数据请求等)
如何创建并发送一个带launch字符串的toast通知
看下面的代码:注意在这里为了创建toast的方便:使用了NotificationsExtensions,关于NotificationsExtensions的使用,参考下面的链接:
使用 NotificationsExtensions 填充锁屏提醒、磁贴和 Toast 模板
private void sendToast(object sender, RoutedEventArgs e){ IToastImageAndText01 toastContent = ToastContentFactory.CreateToastImageAndText01(); toastContent.Launch = "this is launch string test"; toastContent.TextBodyWrap.Text = "破船,恭喜你,中500W!"; toastContent.Image.Src = "/Assets/98_avatar_big.jpg"; ToastNotificationManager.CreateToastNotifier().Show(toastContent.CreateNotification());}
在程序中获得launch字符串
当用户点击或者触摸Toast通知,都会启动相应的程序。并触发OnLaunched事件。
一定要注意:如果在toast通知中没有包含launch字符串,那么OnLaunched是不会被触发的。
下面的代码演示了如何在程序中获得launch字符串
protected override void OnLaunched(LaunchActivatedEventArgs args){ string launchString = args.Arguments ....}
运行效果
1、发送toast通知
2、触发toast通知
3、获取launch字符串
代码下载地址:
http://www.devdiv.com/thread-147671-1-1.html
开发花絮 o(∩_∩)o
- Windows Store apps开发[46]当用户点击Toast通知时,我们可以做些什么
- Windows Store apps开发[67]Windows 8 开发31日-第10日-Toast通知
- Windows Store apps开发[10]通知使用(Toast,Tile和Badge)
- Windows Store apps[9]通知概述(Toast,Tile和Badge)
- 当我们点击了编译时,编译器都为我们做了什么
- Windows Store apps开发[24]选择什么语言来创建Windows Store应用程序?
- Windows Store apps开发[54]数据绑定(3)通知属性改变
- Windows Store apps开发[25]Metro style apps改名为Windows Store apps
- Windows Store apps开发[1]平台简介
- Windows Store apps开发[13]应用程序生命周期
- Windows Store apps开发[44]AppBar总结
- Windows Store apps开发[49]自定义MessageDialog
- Windows Store apps开发[50]自定义Popup
- Windows Store apps开发[23]创建Windows Store应用程序包
- 当服务QPS增高时我们做什么
- Windows Store apps开发[35]如何创建自己的Windows Store账号来提交Apps
- Windows Store apps开发[57]Windows 8 开发31日
- Activity生命周期中我们可以做些什么?
- ServletRequest的应用
- php面试题及答案
- 《当程序员的那些狗日日子》五
- 【Linux学习笔记】做好Linux的管理员:21问
- 火车进站(栈)
- Windows Store apps开发[46]当用户点击Toast通知时,我们可以做些什么
- 《当程序员的那些狗日日子》六
- 《当程序员的那些狗日日子》七
- C3P0数据源配置
- 网络字节序和主机字节序笔记
- 国外.edu邮箱,免费.edu教育邮箱申请
- 去掉桌面快捷方式的箭头的方法
- 用Eclipse编译android程序时,出现警告This text field does not specify an inputType or a hint
- 上海和北京环境各有什么特色?