`
cjz010
  • 浏览: 27690 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

【偶遇BUG】android通知栏的smallicon不生效

阅读更多

【现象】 

 

NotificationManager manager = (NotificationManager) XXXXXXService.this.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder builder = new NotificationCompat.Builder( XXXXXXService.this);

builder.setContentTitle("XXXX");
builder.setContentText("YYYYY");
builder.setAutoCancel(true);

builder.setSmallIcon(R.drawable.ic_launcher);//就是这句话

Notification notification = builder.build();

notification.when = System.currentTimeMillis();

Intent intent = new Intent(getApplicationContext(), YYYYYYYYYActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(XXXXXXXXXXXX, XXXXXX);
PendingIntent pendIntent = PendingIntent.getActivity(getApplicationContext(), subtitle.hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.contentIntent = pendIntent;

manager.notify(subtitle.hashCode(), notification);

     如上代码呈现一个通知栏,但展开通知栏时R.drawable.ic_launcher在GoogleNexus6(android5.1)上是个圆圈加方框的图,收起通知栏的时候更像是个铜钱的形状. 不去自定义RemoteView的情况下,有方案说把那个图片资源背景搞成透明的,但这样的话收起通知栏时那个图片资源不是彩色的.

  

【分析】 

 

    猜想大概是android为了配合新的主题样式,把smallicon改造成了黑白的了.(如果你知道具体原因请留言)

 

【修正】 

    将targetSdkVersion改为20

分享到:
评论

相关推荐

    Notification

    这样一个通知就发送成功了,通知栏上也会显示出SmallIcon图标,之后是进行点击通知进行下载处理,首先Notification发送一个Broadcast广播,但是广播里面不能做耗时操作,所以在广播里开启一个Service服务,通过在...

    android 通知Notification详解及实例代码

    android Notification实例详解 1.使用Builder模式来创建 2.必须要设置一个smallIcon,还可以设置setTicker 3.可以设置 setContentTitle,setContentInfo,setContentText,setWhen 4.可以设置setDefaults(闪屏,...

    C# ListView用法详解

    1、常用的基本属性: (1)FullRowSelect:设置是否行选择模式。(默认为false) 提示:只有在...(4)View:获取或设置项在控件中的显示方式,包括Details、LargeIcon、List、SmallIcon、Tile(默认为 LargeIcon)

    vc++课程设计资源管理器

    SHGFI_SYSICONINDEX | SHGFI_SMALLICON); HTREEITEM subItem = GetTreeCtrl().InsertItem(str, fileInfo.iIcon, fileInfo.iIcon, rootItem); char* newBuff = new char[6]; strcpy(newBuff, pTemp); ...

    java压缩图片程序代码

    * 压缩图片文件 * 先保存原文件,再压缩、上传 * @param oldFile 要进行压缩的文件全路径 * @param width 宽度 * @param height 高度... * @param smallIcon 小图片的后缀 * @return 返回压缩后的文件的全路径

    VC 在ctrlList列表视图中增加Check选框.rar

      m_ctrlList.ModifyStyle(LVS_ICON | LVS_SMALLICON | LVS_LIST, LVS_REPORT);   //设置列表控件使用复选框   m_ctrlList.SetExtendedStyle(LVS_EX_CHECKBOXES);   //在列表控件中插入列   for (int n = 0; n ...

    ListCtrl控件的使用方法

    列表控件可以看作是功能增强的ListBox,它提供了...LVS_ICON ,LVS_SMALLICON ,LVS_LIST, LVS_REPORT 这四种风格决定控件的外观,同时只可以选择其中一种,分别对应:大图标显示,小图标显示,列表显示,详细报表显示。

    java图片生成缩略图

    * @param smallIcon 压缩图片后,添加的扩展名(在图片后缀名前添加) * @param percentage 是否等比压缩 若true宽高比率将将自动调整 * @author zhengsunlei * @return 如果处理正确返回压缩后的文件名 null则...

    浅谈C#中ListView类的用法

    一、ListView类  1、常用的基本属性: (1)FullRowSelect:设置是否行选择模式。...(4)View:获取或设置项在控件中的显示方式,包括Details、LargeIcon、List、SmallIcon、Tile(默认为 LargeIco

    ListView(列表视图)

    using System; using System.Collections.... listView1.View = View.SmallIcon; break; case "列表": listView1.View = View.List; break; case "报告": listView1.View = View.Details; break; } } } }

    TestListControl.zip

    List Control关于Icon/Small Icon/list的用法

    C#程序设计《学生信息显示》

    C#学生信息显示 namespace xuexi6._ { public partial class Form1 : Form { public Form1() { InitializeComponent(); ... public student[] sts = new student[10];... private void initializestudent() ...

Global site tag (gtag.js) - Google Analytics