【起航计划 025】2015 起航计划 Android APIDemo的魔鬼步伐 24 App->Notification->Notifying Service Controller service中使用Notification
这个例子介绍了如何在Service中使用Notification,相关的类为NotifyingController和NotifyingService。
在Service中使用Notification的基本方法和前一例子相同。我们暂时还没有介绍Service的用法。 Service的基本概念和Windows OS中Service基本相同:没有UI,在后台运行。Notification可以说是Service最好的用来通知用户的方法。后面有专门介绍 Service的用法,这里就不说明了。
NotifyingService实现在一分钟内每隔5秒钟显示一个Notification。图标分别为笑脸,无表情,哭脸:
for (int i = 0; i < 4; ++i) {
showNotification(R.drawable.stat_happy,
R.string.status_bar_notifications_happy_message);
if (mCondition.block(5 * 1000))
break;
showNotification(R.drawable.stat_neutral,
R.string.status_bar_notifications_ok_message);
if (mCondition.block(5 * 1000))
break;
showNotification(R.drawable.stat_sad,
R.string.status_bar_notifications_sad_message);
if (mCondition.block(5 * 1000))
break;
}
// Done with our work... stop the service!
NotifyingService.this.stopSelf();
【起航计划 025】2015 起航计划 Android APIDemo的魔鬼步伐 24 App->Notification->Notifying Service Controller service中使用Notification的更多相关文章
- 【起航计划 028】2015 起航计划 Android APIDemo的魔鬼步伐 27 App->Preferences->Launching preferences 其他activity获取Preference中的值
前给例子介绍了如何使用PreferenceActivity 来显示修改应用偏好,用户对Preferences的修改自动存储在应用对应的Shared Preferences中. 本例介绍了如何从一个Ac ...
- 【起航计划 002】2015 起航计划 Android APIDemo的魔鬼步伐 01
本文链接:[起航计划 002]2015 起航计划 Android APIDemo的魔鬼步伐 01 参考链接:http://blog.csdn.net/column/details/mapdigitap ...
- 【起航计划 037】2015 起航计划 Android APIDemo的魔鬼步伐 36 App->Service->Remote Service Binding AIDL实现不同进程间调用服务接口 kill 进程
本例和下个例子Remote Service Controller 涉及到的文件有RemoteService.java ,IRemoteService.aidl, IRemoteServiceCallb ...
- 【起航计划 031】2015 起航计划 Android APIDemo的魔鬼步伐 30 App->Preferences->Advanced preferences 自定义preference OnPreferenceChangeListener
前篇文章Android ApiDemo示例解析(31):App->Preferences->Launching preferences 中用到了Advanced preferences 中 ...
- 【起航计划 027】2015 起航计划 Android APIDemo的魔鬼步伐 26 App->Preferences->Preferences from XML 偏好设置界面
我们在前面的例子Android ApiDemo示例解析(9):App->Activity->Persistent State 介绍了可以使用Shared Preferences来存储一些状 ...
- 【起航计划 020】2015 起航计划 Android APIDemo的魔鬼步伐 19 App->Dialog Dialog样式
这个例子的主Activity定义在AlertDialogSamples.java 主要用来介绍类AlertDialog的用法,AlertDialog提供的功能是多样的: 显示消息给用户,并可提供一到三 ...
- 【起航计划 012】2015 起航计划 Android APIDemo的魔鬼步伐 11 App->Activity->Save & Restore State onSaveInstanceState onRestoreInstanceState
Save & Restore State与之前的例子Android ApiDemo示例解析(9):App->Activity->Persistent State 实现的UI类似,但 ...
- 【起航计划 035】2015 起航计划 Android APIDemo的魔鬼步伐 34 App->Service->Local Service Controller
Local Service Controller 是将LocalService当作“Started”Service来使用,相对于”Bound” Service 来说,这种模式用法要简单得多,Local ...
- 【起航计划 034】2015 起航计划 Android APIDemo的魔鬼步伐 33 App->Service->Local Service Binding 绑定服务 ServiceConnection Binder
本例和下列Local Service Controller 的Activity代码都定义在LocalServiceActivities.Java 中,作为LocalServiceActivities ...
随机推荐
- Vue-Router路由Vue-CLI脚手架和模块化开发 之 路由的动态跳转
在上一篇的博文中,实现的跳转是在页面中进行实现的 利用vue-router实例方法,使用js对路由进行动态跳转: 1.router.push:参数为路由对象,跳转到指定路由,跳转后会产生历史记录: & ...
- poi+properties文件实现多环境测试数据一键切换
在项目的接口测试过程中,之前的测试数据都是测试环境下的,长期在测试环境下运行. 目前希望通过很小的代价切换到线上环境运行. 考虑之下,决定使用poi包加上property文件来实现线上线下的数据切换. ...
- 利用Shell脚本实现远程MySQL自动查询
下面这个脚本是一个简单用来执行远程数据库查询的命令,相信大家都能看得懂,这对于有些需要每天自动检查数据库或是执行某些语句的兄弟,是很有帮助的,只要稍加修改就可以 #!/bin/shHOST=192.1 ...
- 阿里云 Ubuntu16.04 部署 LAMP
1.更新软件源 sudo apt-get update 2.安装Apache sudo apt-get install apache2 3.查看Apache是否安装成功 apache2 –v 如下所示 ...
- 新磁盘创建lvm并挂载
### .查看硬盘 fdisk -l ### 删除分区 fdisk /dev/sdc ### 按d删除,按w保存并退出 ### 创建pv pvcreate /dev/sdc ### 创建 vg vgc ...
- TCP Nagle算法以及延迟确认(即延迟回复ACK)的学习
TCP/IP协议中,无论发送多少数据,总是要在数据前面加上协议头,同时,对方接收到数据,也需要发送ACK表示确认.为了尽可能的利用网络带宽,TCP总是希望尽可能的发送足够大的数据. (一个连TCP接会 ...
- Sublime_text 3 安装 Package Control
作者博文地址:https://www.cnblogs.com/liu-shuai/ 一.自动安装: 1.通过快捷键 ctrl+` 或者 View > Show Console 菜单打开控制台 2 ...
- RSA算法、SSL协议学习笔记
最近学习计算机网络,涉及到SSL协议,我想起了去年密码学课程讲过的非对称加密RSA算法,结合阮老师的博客,写写学习笔记,这里再回忆一下. RSA算法 RSA算法是一种非对称密码算法,所谓非对称,就是指 ...
- kindEditor完整认识 PHP上调用并上传图片说明
最近又重新捣鼓了下kindeditor,之前写的一篇文章http://hi.baidu.com/yanghbmail/blog/item/c681be015755160b1d9583e7.html感觉 ...
- php 自带加密、解密函数
php 自带的加密函数 不可逆的加密函数为:md5().crypt() md5() 用来计算 MD5 哈稀.语法为:string md5(string str); crypt() 将字符串用 UNI ...