PhilJay / MPAndroidChart

A powerful 🚀 Android chart view / graph view library, supporting line- bar- pie- radar- bubble- and candlestick charts as well as scaling, panning and animations.
Other
37.63k stars 9.02k forks source link

saveToGallery(String title) not working? #2734

Open niklasdaute opened 7 years ago

niklasdaute commented 7 years ago

Hey guys i'm tring to work with saveToGallery(String title) in my application and this is how I implemented it in my code:

button2.setOnClickListener(new View.OnClickListener() {
                                                   public void onClick (View v) {
                                                       Toast.makeText(Main.this, "Chart Saved", Toast.LENGTH_SHORT).show();
                                                       piechart.saveToGallery("MyPieChart", 90);
                                                   }
                                               });

The Toast is showing correctly, but unfornutately the chart is not saved to the gallery. There are no error messages or anything and the app doesn't crash. Did i do something wrong? Did i forget to add something? I added the permission to write to external storage in my manifest, by the way.

Thanks!

GoneUp commented 7 years ago

Was it saved to the DCIM folder?

niklasdaute commented 7 years ago

No it wasn't unfortunately, the error is a file not found exception =(

DJMF2015 commented 7 years ago

I faced this issue too. One way round the problem might be to try specifying the SDPath. For example:

            button2.setOnClickListener(new View.OnClickListener() {
                                               public void onClick (View v) {
                                                   Toast.makeText(Main.this, "Chart Saved", Toast.LENGTH_SHORT).show();
                                                   pieChart.saveToGallery(getFileName(fullPath),90)) {
                                               }
                                           });

This is at least, how I got round the issue of saving image to Gallery.