Android - Change Notification Icon

前端 未结 2 442
栀梦
栀梦 2020-12-20 00:49

I would like to know if its possible to have an different Notificationbar Icon than the Launcher or Application Icon. I would like to display an other icon for my push notif

相关标签:
2条回答
  • 2020-12-20 01:07

    For API < 11, the Notification constructor allowed an icon to be specified. For API > 10, the setSmallIcon and setLargeIcon methods for Notifcation.Builder allow much the same thing.

    0 讨论(0)
  • 2020-12-20 01:24
     Notification n  = new Notification.Builder(this)
                        .setContentTitle("New mail from " + "test@gmail.com")
                        .setContentText("Subject")
                        .setSmallIcon(R.drawable.icon)
                        .setContentIntent(pIntent)
                        .setAutoCancel(true)
                        .addAction(R.drawable.icon, "Call", pIntent)
                        .addAction(R.drawable.icon, "More", pIntent)
                        .addAction(R.drawable.icon, "And more", pIntent).build();
    
    
        NotificationManager notificationManager =
            (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    
        notificationManager.notify(0, n);
    

    in above code setSmallIcon and setSmallIcon are for change the notification icon

    0 讨论(0)
提交回复
热议问题