Android Notification 记录
来源:互联网 发布:linux sleep函数实现 编辑:程序博客网 时间:2024/06/05 19:33
用TaskStackBuilder来获取PendingIntent处理点击跳转到别的Activity,首先是用一般的PendingIntent来进行跳转。
直接用PendingIntent来跳转到NotificationShow,在运行效果上来看,首先发送了一条Notification到通知栏上,然后这时,我退出程序,即MainActivity已经不存在了,回到home主菜单,看到Notification仍然存在,当然,我们还没有点击或者cancel它,现在去点击Notification,跳转到NotificationShow界面,然后我们按下Back键,发现直接回到主界面了。现在大多数android应用都是在通知栏中如果有Notification通知的话,点击它,然后会直接跳转到对应的应用程序的某个界面,这时如果回退,即按下Back键,会返回到该应用程序的主界面,而不是系统的主界面。所以用上面这种PendingIntent的做法达不到目的。这里我们使用TaskStackBuilder来做。
显示用TaskStackBuilder.create(this)一个stackBuilder实例,接下来addParentStack();关于这个方法,我们查一下官方API文档:Add the activity parent chain as specified by the
parentActivityName
attribute of the activity (or activity-alias) element in the application's manifest to the task stack builder. 这句话是说添加一个activity,与这个activity的manifest文件中的parentActivityName的属性相关联。那么我们就在manifest文件中添加这个属性
让它的parentActivity为MainActivity,也就是说在NotificationShow这个界面点击回退时,会跳转到MainActivity这个界面,而不是像上面一样直接回到了程序的主菜单。运行一下,最后效果确实是这样。
0 0
- Android Notification 记录
- Android 学习记录 之 notification
- android学习记录(十七)---Notification 精要解析
- ANdroid Notification
- android notification
- android notification
- android notification
- Android Notification
- android notification
- android notification
- android Notification
- Android Notification
- android Notification
- Android notification
- android Notification
- android:Notification
- Android Notification
- Android Notification
- jdbcuser登陆端
- 如何关闭Sublime Text 3的自动更新?
- 7.nginx源码分析之数据结构:ngx_array_t
- 图片上传功能
- php cli 与cgi
- Android Notification 记录
- 在Myeclipse中添加User Library,用户自己的库
- 在Ubuntu14.04下配置eclipse开发ROS
- 新手向:如何理解OpenGL中着色器,渲染管线,光栅化等概念
- 数据结构之"逆波兰树"求解算式 [a + b * (c - d) - e / f]
- Scanner和BufferedReader读取文件速度比较
- 戏(细)说Executor框架线程池任务执行全过程(下)
- asp.net参数之间传递方法总结(修改了几处错误)
- 深度残差网络(ResNet)浅析