消息提示--Notification实践
来源:互联网 发布:java设置时区的方法 编辑:程序博客网 时间:2024/06/05 00:47
消息通知比较常见,主要是用NotificationCompat的一些接口来进行内容设置,有点像AlertDialog的创建,主要是他们的封装都用了Builder;下面给出两段创建和清除消息提示的代码片段。
新建一个消息提示:
public void openNotification() { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.action_share) .setContentTitle("Notification Title").setContentText("Hello World!").setNumber(5).setSubText("this is sub content") .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher)); Intent resultIntent = new Intent(this, MainActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(MainActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); notificationManager.notify("test", 0, mBuilder.build()); }
关闭消息:
public void cancelNotification() { notificationManager.cancelAll(); }
0 0
- 消息提示--Notification实践
- Android Notification消息提示
- Android Notification消息提示
- bootstrap之notification消息提示应用
- Android 使用Notification进行消息提示
- Toast消息提示和Notification通知
- Notification系统提示,模拟短信消息
- Android的消息提示:Toast与Notification的使用
- 第13讲- Android之消息提示Notification
- Android消息提示:AlertDialog、Toast、Notification的使用
- android学习笔记——Notification消息提示
- Web Notification简单实现桌面消息通知(右下角提示)
- android-UI组件实例大全(十三)------消息提示框:Toast和Notification
- 【Android开发】消息提示框与对话框-使用Notification在状态栏上显示通知
- Android实现系统下拉栏的消息提示——Notification
- android-UI组件实例大全(十三)------消息提示框:Toast和Notification
- 消息提示类控件使用之Notification(状 态栏通知)详解
- android Notification实践
- 简单使用SurfaceView实现小球跑动
- Code Style Guidelines for Contributors (一)
- 【2013年度CSDN博客之星】评奖:全文五言句,俺也拉个票
- Shell初识
- diff 与patch
- 消息提示--Notification实践
- ListView优化之ViewType使用
- Perl入门一,通过shell执行perl语句
- 嵌入式,代码调试----GDB扫盲
- linux inotify 监视文件事件
- 图片加载框架---UniversalImageLoader使用(一)
- 图片加载框架--ImageLoader实现(二)
- 注入框架RoboGuice
- 安全卫士分析--号码归属地