используя чертежный вид для создания чертежа, а затем преобразуя его в изображение и сохраняя его в базе данных, когда действие должно закончиться с параметрами обмена и с идеей, что после сохранения изображений эта опция больше не отображается для обмена с другие приложения, но перенаправляет в другое представление.
dv_example = (DrawingView) findViewById(R.id.drawing_view);
saveEditedImage(dv_example.getBitmap());
UseMethod saveEditedImage
private void saveEditedImage(Bitmap bitmap) {
File file = null;
try {
file = createImageFile();
} catch (IOException e) {
Log.e("CreateImageFile", "Error after attempting to create the container file for the image.");
e.printStackTrace();
}
try {
FileOutputStream outputStream = new FileOutputStream(file);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
Log.e("Crop", "Failed to save");
return;
}
Uri uri = FileProvider.getUriForFile(context, context.
getPackageName() + ".provider", file);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(intent);
}
Метод createImageFile ();
private File createImageFile() throws IOException {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
imageFileName = "JPEG_" + timeStamp + "_";
File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File image = File.createTempFile(imageFileName, ".jpg", storageDir );
mCurrentPhotoPath = image.getAbsolutePath();
Log.i("PATH", mCurrentPhotoPath);
return image;
}
Manifest
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:grantUriPermissions="true"
android:exported="false">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths" />
</provider>