Android通知大图标无法正常工作 [英] Android Notification Large Icon not work

查看:537
本文介绍了Android通知大图标无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要一个大的图标添加到我的通知,但是当我运行应用程序,通知显示不出来。当我更改为小图标,它的工作原理,但图标太小。下面是我的code,任何帮助错在哪里?

 位图rawBitmap = BitmapFactory.de codeResource(getResources(),R.drawable.ic_launcher);
NotificationCompat.Builder mBuilder =新NotificationCompat.Builder(本)
    .setLargeIcon(rawBitmap)
    .setContentTitle(警报)
    .setContentText(柑桔PUNCH美汁源已过期);
    NotificationManager纳米=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(1,mBuilder.build());


解决方案

%的的的通知指导列表,您必须:设置一个小图标通过的<一个href=\"http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setSmallIcon(int)\"相对=nofollow> setSmallIcon()方法。一般情况下,该图标看起来像你的应用程序图标,虽然全白了每的的通知图解指南:工具,如通知图标生成可能帮助建立一个合适的小图标。

在Android 5.0以上版本的设备,您可以使用<一个href=\"http://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#setColor(int)\"相对=nofollow>的setColor()设置一个品牌的背景颜色背后的小图标。

大图标的的意味着品牌推广的目的 - 相反,他们应该用来的使其个人并与通知的发送者(即资料图片)或其他信息相关的形象传达通知的含义。

I want to add a large icon to my notification, but when I run the app, the notification doesn't show up. When I change to small icon, it works but icon is too small. Below is my code, any help where is wrong?

Bitmap rawBitmap=BitmapFactory.decodeResource(getResources(),R.drawable.ic_launcher);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
    .setLargeIcon(rawBitmap)
    .setContentTitle("Alert")
    .setContentText("CITRUS PUNCH Minute Maid expired");
    NotificationManager nm= (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(1,mBuilder.build()); 

解决方案

Per the notification guide list of required fields, you must set a small icon via the setSmallIcon() method. Generally, this icon looks like your application icon, although entirely as white over a transparent background per the notification iconography guide: tools such as the Notification Icon Generator may help in building an appropriate small icon.

On Android 5.0+ devices, you can use setColor() to set a branded background color for behind your small icon.

Large icons are not meant for branding purposes - instead, they should be used to make it personal and be an image associated with the sender of the notification (i.e., a profile picture) or additional information to convey the meaning of the notification.

这篇关于Android通知大图标无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆