0

As we know, we can create bitmap from View. But is it possible to create bitmap on background class like WorkManager's Worker?

My requirement is, I have to show notification with image on daily basis, this image will generated on background with dynamic data. For this I have a Layout with TextViews, I tried to bind data to this TextViews and then converted this layout as bitmap, but it creates empty bitmap.

Gunaseelan
  • 14,415
  • 11
  • 80
  • 128
  • show what you tried – Vladyslav Matviienko Jul 17 '19 at 05:29
  • If you have `Context` for inflater then you can try [This](https://stackoverflow.com/questions/17189809/is-it-possible-to-take-a-screenshot-of-a-view-without-showing-the-view).. I am not sure about it though.. – ADM Jul 17 '19 at 05:31
  • @ADM This method is working only on foreground, in background initially it says `To create bitmap, width and height should not be zero, so I fixed the size in layout, then it creates empty bitmap. – Gunaseelan Jul 17 '19 at 05:33
  • @Gunaseelan can you not just use a custom layout in notification which has a textview and then just add text to textview. Do you want the image only? – Raghunandan Jul 17 '19 at 06:29
  • @Raghunandan If it is image than I can share/save. – Gunaseelan Jul 17 '19 at 06:43
  • not sure if this helps. try inflating a custom imageview in notification and then draw dynamic text on that. not sure. but this off the top of my head. If you find a better way pls do share that as answer. will help a lot – Raghunandan Jul 17 '19 at 06:49

0 Answers0