是否可以使用自定义的(非绘制)smallIcon在Android通知? [英] Is it possible to use a custom (non drawable) smallIcon in an Android notification?

查看:84
本文介绍了是否可以使用自定义的(非绘制)smallIcon在Android通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过一个URL中使用的图标,而不是一个已经包含绘制。这可能吗?为 setSmallIcon 的唯一方法签名接受一个可绘制资源一个int。

I would like to use an icon via a url as opposed to an already included drawable. Is this possible? The only method signature for setSmallIcon accepts an int for a Drawable resource.

不过,我能做些什么,如果我想在我正在发送推送通知smallIcon? (比方说,比如其他用户的Gravatar)。

However, what can I do if I want to include a smallIcon in the push notification that I'm sending? (Let's say for instance another user's gravatar).

推荐答案

没有,你不能设置一个自定义的 smallIcon 的通知,按照该的文档和的培训部分。然而,随着CommonsWare评论,你可以设置自定义 largeIcon 。当用户展开的通知面板,或在Android上的单挑通知5.0+(当优先级至少 HIGH )这类型的图标显示。这可以通过调用来完成 setLargeIcon(MYBITMAP)你的 Notification.Builder 对象。 MYBITMAP 可以是任何位图对象,从互联网上下载或以其他方式。

No, you cannot set a custom smallIcon for a notification, as per the documentation and training section. However, as CommonsWare commented, you can set a custom largeIcon. This type of icon is shown when the user expands the notification panel, or on the "heads-up" notifications in Android 5.0+ (when the priority is at least HIGH). This can be done by calling setLargeIcon(myBitmap) on your Notification.Builder object. myBitmap can be any Bitmap object, loaded from the internet or otherwise.

我相信这背后的理由是,使用户可以随时快速确定哪些应用程序正在试图通知他们。否则,用户将不得不揣摩的时候只是快速检查通知了每个新图标的意思。

I believe the reasoning behind this is so that the user can always quickly identify which apps are trying to notify them. Otherwise, the user would have to try to figure out what each new icon meant when just quickly checking notifications.

这篇关于是否可以使用自定义的(非绘制)smallIcon在Android通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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