如何在收到的Android通知中设置默认的smallIcon和largeIcon?

时间:2016-05-13 20:51:26

标签: android notifications icons pushbots

我实际上正在使用PushBots为我的应用程序实施GCM通知。

当我创建通知时,他们给我选项,使用特定字段,我可以为我的推送设置largeIcon。如果我使用它,我得到这样的东西:

enter image description here

但是,如果我不使用它,我明白了:

enter image description here

我想知道是否可以为我的应用收到的每个通知(推送)设置默认smallIconlargeIcon,或者更改为我自己的应用图标显示的白色框。

1-注意:我没有在我的代码中创建通知,我是在PushBots网站的Drashboard中创建的。

2-注意:largeIconsmallIcon

enter image description here

感谢。

2 个答案:

答案 0 :(得分:1)

最后,在看了PushBots的源代码后,我发现了一个解决方案。

在Android Studio中,转到File -> New -> Image Asset。然后,选择Notification Icon。现在自定义新的小图标,在完成之前,为此新资产添加名称white_notification_icon

Android Studio会告诉您该文件已存在且将被覆盖。说是。

现在,默认情况下你已经设置了一个smallIcon!

答案 1 :(得分:0)

  

请参阅以下代码

<form name="myForm">
    <input type="button" value="confirm" onclick="submitFunction()"/>
</form>
<script>
    function submitFunction(){
        document.getElementById("demo").innerHTML = "Hi How are you?";
    }
</script>
<div id="demo"></div>
  

根据指南,小图标是强制性的,应为白色或灰色,带有背景refer this answer for more details