提示服务Notification在Android中的应用
来源:互联网 发布:让淘宝显示多个客服 编辑:程序博客网 时间:2024/06/05 19:56
短信来了,手机会发出震动或者声音通知,同时在手机上面会显示带图标的提示信息,这就是手机上的提示功能,同样地,在Android的开发中,也为我们提供了提示的相应接口。本文ATAAW.COM就将对Android中提示服务Notification做下讲解。
这里我们通过分析一个Notification的具体实现过程来,来了解Notification服务是如何实现和取消的。
A、首先需要获取系统Notification服务
NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
B、创建Notification,参数为别为图标、提示标题、提示时间
Notification notification = newNotification(R.drawable.n,"即兴提示!",System.currentTimeMillis());
C、创建意图Intent并转化为非即时意图,这样就可以在任何不确定时间被执行
Intent intent = new Intent(this,NewActivity.class);
PendingIntent contentIntent =PendingIntent.getActivity(this,0,intent,0);
D、设置Notification标题、内容和触发事件
notification.setLatestEventInfo(this, "ATAAW.COM", "即兴时代!",contentIntent);
E、开启提示
notificationManager.notify(1,notification);
F、取消提示
Android中的提示服务如上所示,当开启Notification的时候,提示信息就会显示在手机上,并在手机状态栏上有一个图标显示着,当点击这个提示就会触发事件,这时会开启NewActivity,而通过提示服务的calcel方法则可以取消提示。notificationManager.cancel(1);
- 提示服务Notification在Android中的应用
- 提示服务Notification在Android中…
- Notification在Android中的应用
- Android中的Notification初步应用
- 在Android中使用Notification进行提示
- 在Android中使用Notification进行提示
- 在Android中使用Notification进行提示
- Android 应用开发笔记 - 状态栏提示(Notification、NotificationManager)
- Android Notification消息提示
- Android 提示 Notification 通知
- Android Notification消息提示
- android中的提示类组件toast,dialog,notification,widget
- 教程:在Android中使用Notification进行提示
- android notification 应用123
- android notification设置提示音
- Android中的Notification
- android中的Notification使用
- Android中的Notification
- android ListView实现圆角(两种解决方案)
- 反编译Android程序APK文件的方法
- Android开发中单选框控件RadioButton的使用
- 使用地图控件MapView如何申请apiKey
- Android下拉框控件Spinner的使用
- 提示服务Notification在Android中的应用
- 在Android程序代码中实现软件安装和卸载
- Android十日学习路线
- 在Android中Preferences数据存储的使用
- Android星星评分控件RatingBar的使用
- installshield中常用prq文件的下载地址
- 使用TextWatcher实现EditText与TextView同步
- 使用Intent启动常用的应用与服务
- fread函数 & fwrite函数