کد:
public void save_image() {
File root = android.os.Environment.getExternalStorageDirectory();
File dir = new File(root.getAbsolutePath() + "/IMAGE_TATAK");
dir.mkdirs(); // build directory
file = new File(dir, backgroundImageName);
if (file.exists())
file.delete(); try {
FileOutputStream outStream = new FileOutputStream(file);
InputStream ims = getAssets().open("image/" + backgroundImageName);
Bitmap bitmap = BitmapFactory.decodeStream(ims);
try {
ims.close();
ims = null;
}
catch (IOException e) {}
bitmap = mark(bitmap, null);
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, outStream);
outStream.flush();
outStream.close();
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
new SweetAlertDialog(this, SweetAlertDialog.SUCCESS_TYPE)
.setTitleText("Save to gallery")
.show();
}
کد:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));