Android中的通知 Notification
2016-05-10 22:05
375 查看
通知是Android中的一个系统服务。
NotificationManager
Android中如何发送一个通知?
1>获取系统服务NotificationManager。
2>构建一个Notification对象。Notification.Builder
3>调用manager.notify(Notification)方法发送通知。
如何使用代码清除通知?
NotificationManager manager=(NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
manager.cancel(id);
如何使通知常驻通知栏?
notification.flags=Notification.FLAG_NO_CLEAR;
如何更新Notification上面的内容?
1> 重新发送一条新内容的通知即可。
(使用同一个id)
如何点击通知后响应点击意图?
//添加通知的点击意图
Intent i=new Intent(this, MainActivity.class);
PendingIntent pi=PendingIntent.getActivity(this, 0, i, 0);
builder.setContentIntent(pi);
NotificationManager
Android中如何发送一个通知?
1>获取系统服务NotificationManager。
2>构建一个Notification对象。Notification.Builder
3>调用manager.notify(Notification)方法发送通知。
如何使用代码清除通知?
NotificationManager manager=(NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
manager.cancel(id);
如何使通知常驻通知栏?
notification.flags=Notification.FLAG_NO_CLEAR;
如何更新Notification上面的内容?
1> 重新发送一条新内容的通知即可。
(使用同一个id)
如何点击通知后响应点击意图?
//添加通知的点击意图
Intent i=new Intent(this, MainActivity.class);
PendingIntent pi=PendingIntent.getActivity(this, 0, i, 0);
builder.setContentIntent(pi);
相关文章推荐
- Android的Handler,Looper消息机制问题
- android studio 学习笔记之 全面进阶配置技巧
- 【Android】自定义View —— 滑动的次数选择器
- ExpandableListView二级分栏详解完美用法
- Android View的事件分发
- Android——tabHost的使用注意点
- android:screenOrientation属性详解
- Exception raised during rendering: Could not initialize class android.widget.TextView Exception deta
- Android自定义Toast带图片的
- 马上搞定Android平台的Wi-Fi Direct开发
- AndroidManifest.xml详解
- android 6.0 textview 跑马灯失效和出现抖动的解决方法
- Android中级篇之Fresco-加载图片基础[详细图解Fresco的使用]
- Android 6.0开始动态请求权限
- Android之根据Uri获得图片或视频文件路径(解决4.4以上版本得不到路径的情况)
- Android虚拟机怎么启动不起来,一直停在启动界面
- Android从按下开机键到启动发生了什么
- Android动画最新最全详解包含Material Design动画
- Android:控件布局(相对布局)RelativeLayout
- Android数据适配器(Adapter)优化:高效ViewHolder