enter image description here我想从Firebase获取“推送通知”上的不同图标,但是这里的默认图标每次都可见。那我该怎么办?
<v-container>
<v-row justify="center">
Hello I am center to vertically using "grid".
</v-row>
</v-container>
答案 0 :(得分:0)
确保在您的AndroidManifest文件中,已设置Firebase通知的图标,如下所示:
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/myLogo" />
// Here, instead of myLogo you can put the drawable you want.
目前在Android中无法动态设置小通知图标,只能以这种方式设置大图标。您需要在本地存储相关小图标的可绘制对象,并在构建通知时使用适当的图标。样本:
// URL value is your URL to the image
Bitmap mIcon1 = BitmapFactory.decodeStream(url_value.openConnection().getInputStream());
NotificationCompat.Builder builder=new NotificationCompat.Builder(this,"mynotification")
.setContentTitle(title)
.setSmallIcon(R.drawable.myLogo)
.setLargeIcon(mIcon1)
.setAutoCancel(true)
.setContentText(message);
代替使用URL,您可以从任何地方将大图标加载为位图,但不能加载小图标,因为setSmallIcon()要求从其定义开始就将id分配给本地存储的资源:
/**
* Set the small icon to use in the notification layouts. Different classes of devices
* may return different sizes. See the UX guidelines for more information on how to
* design these icons.
*
* @param icon A resource ID in the application's package of the drawable to use.
*/
public Builder setSmallIcon(int icon) {
mNotification.icon = icon;
return this;
}
答案 1 :(得分:0)