28-05-1395، 02:00 ق.ظ
برای ذخیره عکس از متد زیر استفاده می کنم اما از اندروید 5 به بعد برنامه کرش میکنه مشکل کجاست؟.. ممنون
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())));