Widget,RemoteViews, AppWidgetProvider, ImageView, Bitmap, GraphicalView.toBitmap

Showing 1-3 of 3 messages
Widget,RemoteViews, AppWidgetProvider, ImageView, Bitmap, GraphicalView.toBitmap Michael Weisser 9/17/11 12:37 PM
Hello,

I want to integrate charts from AChartEngine into my widgets. I use the ImageView component in my widget layout and I try to update this ImageView (RemoteViews.setImageViewBitmap) with the Bitmap result from the AChartEngine method GraphicalView.toBitmap().

My problem right know is that GraphicalView.toBitmap() always return null in my context!

I create the XYMultipleSeriesDataset, XYMultipleSeriesRenderer, GraphicalView in the AppWidgetProvider.onUpdate method... This is also the place where i call the GraphicalView.toBitmap() method with the context given by the AppWidgetProvider.onUpdate method.


Does anybody use AChartEngine charts in a homescreen-widget? And if yes please can you provide me some hints or examples???

Thanks in advance and Kind Regards
Michael

Re: Widget,RemoteViews, AppWidgetProvider, ImageView, Bitmap, GraphicalView.toBitmap Michael Weisser 9/22/11 5:41 AM

Short update on this topic.  I got an example how this could be implemented from the author of the GraphView Library - http://www.jjoe64.com/p/graphview-library.html


In AChartEngine GraphicalView create a new method, e.g. saveToBitmap

  public void saveToBitmap(Bitmap pBitmap) {
 Canvas lCanvas = new Canvas(pBitmap);
 onDraw(lCanvas);
  }


In AppWidgetProvider.onUpdate do the following:

- Create the GraphicalView 
- Create a new Bitmap, e.g. lBitmap = Bitmap.createBitmap(146, 72, Bitmap.Config.ARGB_8888);
- Invoke GraphicalView.saveToBitmap(lBitmap)
- Use this Bitmap to update your RemoteViews.setImageViewBitmap(id, lBitmap);


Even it works I am not so happy with my current results... I will still do some more research on this and also testing some other libs.

Thanks to Jonas (http://www.jjoe64.com/) for pointing me to this solution

Regards
Michael

Re: Widget,RemoteViews, AppWidgetProvider, ImageView, Bitmap, GraphicalView.toBitmap Chris Chan 10/2/12 7:30 AM
Hi Michael,

I'm new to Android dev and am trying to do the same.
Would it be possible to see a sample of your onUpdate code in your provider?  That would help out a lot!

Thanks!
Chris