I am not sure what I am doing wrong exactly but keep getting this error while trying to save the bitmap into a png file and send to another Activity:
private void savePhoto() {
resolver = getContentResolver();
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.MediaColumns.DISPLAY_NAME, "Image_" + ".jpg");
contentValues.put(MediaStore.MediaColumns.MIME_TYPE, "image/jpeg");
contentValues.put(MediaStore.MediaColumns.RELATIVE_PATH, Environment.DIRECTORY_PICTURES + getFilesDir() + File.separator + "TextPhoto");
imageUri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
// outputMediaFile.createNewFile();
SaveSettings build = new SaveSettings.Builder().setClearViewsEnabled(true).setTransparencyEnabled(true).build();
if (ActivityCompat.checkSelfPermission(this, "android.permission.WRITE_EXTERNAL_STORAGE") == 0) {
mPhotoEditor.saveAsFile(new File(imageUri.getPath()).getAbsolutePath(), build, new PhotoEditor.OnSaveListener() {
public void onFailure(Exception exc) {
}
public void onSuccess(String str) {
listPhoto.set(position, str);
EditPhotoActivity editPhotoActivity = EditPhotoActivity.this;
intent.putStringArrayListExtra("AFTER", listPhoto);
editPhotoActivity.setResult(115, editPhotoActivity.intent);
finish();
}
});
}
}
内容架构content://
不是 File 架构file://
不能在File
类中使用
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.