2016-03-01 159 views
0

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

.setSmallIcon(applicationContext.getApplicationInfo().icon) 

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

回答

0
.setSmallIcon(R.drawable.your_icon) 

enter image description here

+0

我怎么把我的图标绘制的命名空间? –

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()); 
+0

谢谢,但我该如何将我的图标放在可绘制名称空间中? –

+0

只需将您的图标添加到可绘制的文件夹中即可 – theremin