Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a Bitmap as a Notification Icon

I want to draw something on a pic , after do that , it is a Bitmap . i want to add this Bitmap to the Notification as its icon. but it the icon must be a int Id . How can i make it? thanks for your answer~~~~ pls hlep me!

like image 382
Daniel Zhao Avatar asked Oct 25 '12 05:10

Daniel Zhao


People also ask

How do you set a notification picture on android?

To add an image in your notification, pass an instance of NotificationCompat. BigPictureStyle to setStyle() .

How do you add icons to push notifications?

Navigate to Messages > New Push > Platform Settings > Google Android Options > Set the icon name without the file extension. With Large Notification Icons, you can also supply a URL where the icon will be displayed from.

What is NotificationCompat builder?

Builder class for NotificationCompat objects. Allows easier control over all the flags, as well as help constructing the typical notification layouts. On platform versions that don't offer expanded notifications, methods that depend on expanded notifications have no effect.


2 Answers

From this Post i came to know that Notification icon will take Resources image. So You cant do dynamic in Small icon. But you can do for large icon from Api Level 11.

For that you can use Notificaiton.Builder Refer here

Other way is also there. That is you can change icon that appears when notification in pulled down. For that you have to Use RemoteViews

Refer here

like image 127
Abhi Avatar answered Sep 22 '22 11:09

Abhi


You can put image file in res->drawable (or drawable-hdpi,ldpi,mdpi), for example notify.png and use it

myNotification = new Notification(R.id.notify, "Notification!", System.currentTimeMillis());

or

Try using AnimationDrawable's. You can use them to combine multiple drawables into a single one, and select the one you want to display. I really think, this is the way to go.

More info: AnimationDrawable

Off course, you will have to provide individual drawables for all your Integers you want to display, but this way, you can easily change the appearance of your notifications

like image 2
Jay Avatar answered Sep 20 '22 11:09

Jay