2016-03-01 508 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