之前一直在琢磨Glide自定义使用中的一些经验;今天简单的分享下Notification中使用Glide去加载icon方法;

我们都知道使用android通知时,一般可能会有如下代码:

NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setSmallIcon(R.mipmap.future_studio_launcher)
.setContentTitle("Title")
.setContentText("Text")
.setContent(cView)//这里是你定义布局产生的对象
.setPriority( NotificationCompat.PRIORITY_MIN); final Notification notification = mBuilder.build();
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(xxxxx, notification);//Notification的使用是需要系统服务支持的,而且还需要你提供一个id=xxxxx

到了Glide设置notification时又变成了极其简单的操作,代码如下:

NotificationTarget notificationTarget = new NotificationTarget(context,
cView,//通知展示的xml对象实例
R.id.ImageView_notification_icon,//布局中ImageView的id
notification,//通知的对象实例
xxxxx);//通知的对象实例对应的id

之后直接调用into插入NotificationTarget对象即可:

Glide
.with( context)
.load( eatFoodyImages[3] )
.asBitmap()
.into( notificationTarget );

最新文章

  1. Arcengine 中,创建色带
  2. gcc常用选项
  3. Java中获得程序当前路径的4中方法
  4. 网络负载均衡环境下wsHttpBinding+Message Security+Windows Authentication的常见异常
  5. 自动化测试框架Selenium工作原理
  6. 安卓Eclipse开发者的福音
  7. 高性能队列——Disruptor
  8. 创建 Pull Request
  9. Kube-DNS搭建(1.4版本)
  10. Android兼容包之MultiDex
  11. Windows核心编程:第5章 作业
  12. CSS3关于-webkit-tap-highlight-color属性
  13. 项目复审——Beta阶段
  14. spring mvc interceptors
  15. 记录GOPATH在GOLAND中的坑
  16. 131. 分割回文串 javascript实现
  17. 系统日志查看logrotate 工具
  18. java学习笔记6--类的继承、Object类
  19. XUtils3框架的初始体验(一)
  20. Oracle 数据库的组成(instance+database)

热门文章

  1. whose view is not in the window hierarchy
  2. nginx,apache,tomcat配置https的阿里提供的文档
  3. 【C#】MVC项目中搭建WebSocket服务器
  4. MongoDB的用户管理(6)
  5. 移动端横屏(beta)
  6. 浏览器-04 WebKit 渲染2
  7. Html_color code表示
  8. Node.js-Socket.IO【1】-身份验证
  9. 求两条线段交点zz
  10. React组件属性部类(propTypes)校验