Null Pointer while exporting charts in android
<p>Email works well with small charts but large charts fail to export and give a null pointer exception.<br>
    case email:</p>

<pre><code>try {

  new LoadAllData().execute();
  pDialog.setMessage("Please wait..");

             doExport();

            } catch (IOException e) {
                e.printStackTrace();

                dialog = new Dialog(testActivity.this);
                dialog.setContentView(R.layout.description);
                dialog.show();
                dialog.setTitle("Access Denied!");
                description = (TextView) dialog.findViewById(R.id.descriptionText);
                description.setText("Cannot export Chart: " +    e.getMessage());
                description.setTextColor(0xFFFFFFFF);
                okButton = (Button) dialog.findViewById(R.id.okButton);
                okButton.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        dialog.cancel();
                    }
                });
            }
</code></pre>

<p>code for export </p>

<pre><code>  private void doExport() throws IOException {
    final Intent sendIntent = new Intent(Intent.ACTION_SEND);
    final Image image = chart.getExport().getImage()
            .image(chart.getWidth(), chart.getHeight());

    File file;
    final FileOutputStream stream;

    file = new File("/sdcard/test.png");
    stream = new FileOutputStream(file);

    image.save(stream);
    stream.flush();
    stream.close();

    sendIntent.setType("image/png");
    sendIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file:///sdcard/test.png"));

    startActivity(Intent.createChooser(sendIntent, "Export"));
}
</code></pre>

<p>Here is the logcat</p>

<pre><code>  12-03 13:59:32.174: E/AndroidRuntime(11871): java.lang.NullPointerException
  12-03 13:59:32.174: E/AndroidRuntime(11871): at    com.sympo.test.android.testActivity.doExport(testActivity.java:8261)
 12-03 13:59:32.174: E/AndroidRuntime(11871):   at com.sympo.test.android.testActivity.MenuItemSelectedEvent(testActivity.java:8215)
 12-03 13:59:32.174: E/AndroidRuntime(11871):   at com.sympo.test.android.CustomMenuListener$1.onClick(CustomMenuListener.java:166)
 12-03 13:59:32.174: E/AndroidRuntime(11871):   at android.view.View.performClick(View.java:4101)
 12-03 13:59:32.174: E/AndroidRuntime(11871):   at android.view.View$PerformClick.run(View.java:17078)
 12-03 13:59:32.174: E/AndroidRuntime(11871):   at android.os.Handler.handleCallback(Handler.java:615)
 12-03 13:59:32.174: E/AndroidRuntime(11871):   at android.os.Handler.dispatchMessage(Handler.java:92)
 12-03 13:59:32.174: E/AndroidRuntime(11871):   at android.os.Looper.loop(Looper.java:155)
 12-03 13:59:32.174: E/AndroidRuntime(11871):   at android.app.ActivityThread.main(ActivityThread.java:5485)
 12-03 13:59:32.174: E/AndroidRuntime(11871):   at java.lang.reflect.Method.invokeNative(Native Method)
 12-03 13:59:32.174: E/AndroidRuntime(11871):   at java.lang.reflect.Method.invoke(Method.java:511)
 12-03 13:59:32.174: E/AndroidRuntime(11871):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
</code></pre>

<p>I am getting a null pointer exception on doExport() method. I suspect may be the chart is too large because the code works with other small charts perfectly anybody with an idea of how to go about it ?</p>
