简体   繁体   中英

Changing the notification icon

I would like to set another default icon for my notification. I use the notification service of parse.com and would like to change the icon in the notification bar.

Is that possible without changing the title and the text with Notification.Builder ?

Post your source code on how you create your notification.

But in general, to change the notification icon, you just call the method setSmallIcon or setLargeIcon. Here's an example:

 Notification notif = new Notification.Builder()
     .setContentTitle("New mail from " + sender.toString())
     .setContentText(subject)
     .setSmallIcon(R.drawable.new_mail)
     .setLargeIcon(aBitmap)
     .build();

In your case, just supply a different icon drawable to the setSmallIcon method.

In android lower than ICS

Notification notification = new Notification(R.drawable.logo, "", System.currentTimeMillis());
notification.largeIcon = your bitmap
notification.icon = your drawable

You have to implement a custom receiver for the Parse Push Notifications as described in Parse's documentation .

By doing this, Parse is not automatically generating a User Notification in Android and you can then do this yourself with Notification.Builder in newer Android version and Notification() in older Android version as described in the other answers and there provide your custom icon.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM