title: Android converting graph (AChartEngine) into image using toBitmap()
body: <p>I am trying to add graph to my Android application using <em>AChartEngine</em>. The only thing different from examples is that I want to make from graph bitmap and then insert into <code>ImageView</code>.</p>
  
  <p>I am able to add graph without any problems to the LinearLayout, but after using method <code>toBitmap()</code> on graph and inserting it into <code>ImageView</code> I don't have anything and get <code>NullPointerException</code>. <strong>The possible problem that I've found is ID of generated graph which is -1</strong>.</p>
  
  <p>This is the code:</p>
  
  <pre><code>public class Chart extends Activity{
  
  /** The main dataset that includes all the series that go into a chart. */
            private XYMultipleSeriesDataset mDataset = new XYMultipleSeriesDataset();
            /** The main renderer that includes all the renderers customizing a chart. */
            private XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
            /** The most recently added series. */
            private XYSeries mCurrentSeries;
            /** The most recently created renderer, customizing the current series. */
            private XYSeriesRenderer mCurrentRenderer;
            /** The chart view that displays the data. */
            private GraphicalView mChartView;
  
            @Override
            protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.widget_layout);
  
              // set some properties on the main renderer
              mRenderer.setAxisTitleTextSize(16);
              mRenderer.setChartTitleTextSize(20);
              mRenderer.setLabelsTextSize(15);
              mRenderer.setLegendTextSize(15);
              mRenderer.setPointSize(5);
            }
  
            @Override
            protected void onResume() {
              super.onResume();
              if (mChartView == null) {
                initChart();
                addSampleData();
                mChartView = ChartFactory.getLineChartView(this, mDataset, mRenderer);
                mRenderer.setClickEnabled(true);
                mRenderer.setSelectableBuffer(10);
                Bitmap img = mChartView.toBitmap();
                  ImageView imgView = (ImageView)findViewById(R.id.graphView);
                  imgView.setImageBitmap(img);
              } else {
                mChartView.repaint();
              }
            }
  
  }
  </code></pre>
  
  <p><strong>Can someone tell me what should I do to generate image and insert it normally?</strong></p>