Android快速实现通知栏提醒功能
来源:互联网 发布:php开发技术 编辑:程序博客网 时间:2024/06/09 00:17
Android快速实现通知栏提醒功能
日常的安卓开发过程中,经常会使用到通知栏去进行通知的功能,如何简单快速的将通知栏提醒功能集成到自己的项目之中,这篇文章将通过简短的代码展示,现在官方推荐的是这种使用builder的方式去创建通知栏的提示信息,之前的通过set
builder = new Notification.Builder(this); builder.setSmallIcon(R.drawable.icon); //设置图标 builder.setTicker("通知提示"); builder.setContentTitle("通知"); //设置标题 builder.setContentText("点击查看详细内容"); //消息内容 builder.setWhen(System.currentTimeMillis()); //发送时间 builder.setDefaults(Notification.DEFAULT_ALL); //设置默认的提示音,振动方式,灯光 builder.setAutoCancel(true);//打开程序后图标消失 Intent intent = new Intent(MainActivity.this, Center.class); PendingIntent pendingIntent = PendingIntent.getActivity(MainActivity.this, 0, intent, 0); builder.setContentIntent(pendingIntent); Notification notification1 = builder.build(); notificationManager.notify(124, notification1); // 通过通知管理器发送通知 this.updateNotification = builder.getNotification();
实现代码
builder.setTicker("正在下载"); builder.setContentTitle(title); //设置标题 builder.setProgress(100, (int) totalSize * 100 / updateTotalSize + 9, false); builder.setContentText("当前下载进度:"+(int) totalSize * 100 / updateTotalSize + "%"); //消息内容 // builder.setContentIntent(updatePendingIntent); updateNotification = builder.getNotification(); updateNotificationManager.notify(0, updateNotification);
1 0
- Android快速实现通知栏提醒功能
- Android定时推送通知/提醒功能的实现
- 四种通知栏提醒,Android实现通知栏提醒方法,手机通知栏适配测试Demo
- AlarmManager+Notification实现定时通知提醒功能
- Ios开发中UILocalNotification实现本地通知实现提醒功能
- iOS开发 UILocalNotification 本地通知实现提醒功能
- iOS开发 UILocalNotification 本地通知实现提醒功能
- Android拦截短信并通知栏提醒
- android 通知提醒
- android实现消息提醒,拨打电话功能
- Android之下次不再提醒功能实现
- android 每天定时提醒功能实现
- Android后台定时提醒功能实现
- Android后台定时提醒功能实现
- android 每天定时提醒功能实现
- Android后台定时提醒功能实现
- 实现 Android 通知提示功能
- 本地通知(UILocalNotification)的学习和使用(通过本地通知实现提醒功能)
- OC中的类方法与实例方法
- 简单实现二叉树
- hud 1892 (二维树状数组)
- 剑指offer--面试题10:二进制中1的个数
- 练习搭建spring+springmvc+mybatis实现java web登陆
- Android快速实现通知栏提醒功能
- Qt5--Qt模块简介
- 近百种Android项目源码
- socket 通讯检测客户端非正常断线。
- JAVA学习34_java类加载全过程
- java Pattern和Matcher——用于匹配和查找字符串中的内容
- Android中的onNewIntent()牛刀小试
- 第3章: zookeeper命令行使用
- gulp使用