Android推送通知图标

时间:2016-03-01 15:53:39

标签: android push-notification icons

通常我会在推送通知中使用我的应用程序图标。

.setSmallIcon(applicationContext.getApplicationInfo().icon)

如何在不同的推送通知中使用不同的自定义图标(我自己创建的)?

2 个答案:

答案 0 :(得分:0)

 .setSmallIcon(R.drawable.your_icon)

enter image description here

答案 1 :(得分:0)

NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
        .setContentTitle(notificationTitle)
        .setContentText(notificationMessage)
        .setSmallIcon(R.drawable.YOUR_IMAGE)
        .setContentIntent(resultPendingIntent)
        .setAutoCancel(true)
        .setStyle(bigStyle);

NotificationManager notificationmanager = (NotificationManager)context.getSystemService(context.NOTIFICATION_SERVICE);
notificationmanager.notify(nofy_id, builder.build());