android显示一个通知
2015-09-29 10:10
417 查看
简单的显示一个通知栏提醒
Notification notification = new Notification(icon, tickerText, when);
//点击可以取消通知
notification.flags=Notification.FLAG_AUTO_CANCEL;
//通知时亮屏,震动,提示音
notification.defaults = Notification.DEFAULT_ALL;
//通知等设置
notification.ledARGB=0x00ff00;
notification.ledOffMS=100;
notification.ledOnMS=100;
//定义下拉通知栏时要展现的内容信息
CharSequence contentTitle = "效率大师打卡提醒";
CharSequence contentText = "亲~不要忘了打卡呦~";
Intent notificationIntent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText,contentIntent);
mNotificationManager.notify(1, notification);
Notification notification = new Notification(icon, tickerText, when);
//点击可以取消通知
notification.flags=Notification.FLAG_AUTO_CANCEL;
//通知时亮屏,震动,提示音
notification.defaults = Notification.DEFAULT_ALL;
//通知等设置
notification.ledARGB=0x00ff00;
notification.ledOffMS=100;
notification.ledOnMS=100;
//定义下拉通知栏时要展现的内容信息
CharSequence contentTitle = "效率大师打卡提醒";
CharSequence contentText = "亲~不要忘了打卡呦~";
Intent notificationIntent = new Intent(context, MainActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0,notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText,contentIntent);
mNotificationManager.notify(1, notification);
相关文章推荐
- 在《Android PorterDuff.Mode图形混合处理 》这篇博客中,我们讲解了PorterDuff.Mode对图形混合的处理。这篇我们将通过图形混合的原理,来制作一个手动擦除蒙版显示底层图片
- Android采用Volley具体的例子展示完整的异步加载数据(一)
- Android自定义控件——圆形ImageView
- Android百分比布局初探
- Android中实现第三方分享
- Android Hook框架Xposed原理与源代码分析
- Android高效加载大图、多图解决方案,有效避免程序OOM
- Android 开源框架Universal-Image-Loader完全解析(三)---源代码解读
- Android -- 使用inBitmap要注意的地方
- Android动画浅谈之Animation动画
- Android 开源框架Universal-Image-Loader完全解析(二)--- 图片缓存策略详解
- Android事件分发机制——View(一)
- Android 开源框架Universal-Image-Loader完全解析(一)--- 基本介绍及使用
- Android 开发中的日常积累
- Android关于Log不能打印的问题
- android获取apk安装包信息
- Android Phone模块详解
- Android 仿酷狗滑动控件实现 流畅运行
- ListView位置记录
- android Phone中的消息处理过程