I am using the MPAndroidChart to render various charts. I wanted to add the functionality of saving the charts as images to the gallery. I added an icon to the action bar to use this functionality, but the image does not save to the gallery.
The code is given below :
<item android:id="@+id/save"
android:icon="@drawable/ic_action_accept"
android:title="@string/save"
app:showAsAction="always"/>
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
switch (item.getItemId()) {
case R.id.save :
mlineChart.saveToGallery("Chart",50);
return true;
case R.id.action_settings :
return true;
default: return super.onOptionsItemSelected(item);
}
}