To share an image from an ImageView in your Sketchware Android project,
in VIEW area add a Button button1, which will act as a share button.
In the event of on button1 click, use an add source directly block and put following code in it:
Bitmap bm = ((android.graphics.drawable.BitmapDrawable) imageview1.getDrawable()).getBitmap();
try {
java.io.File file = new java.io.File(getExternalCacheDir() + "/image.jpg");
java.io.OutputStream out = new java.io.FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
} catch (Exception e) { showMessage(e.toString()); }
Intent iten = new Intent(android.content.Intent.ACTION_SEND);
iten.setType("*/*");
iten.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new java.io.File(getExternalCacheDir() + "/image.jpg")));
startActivity(Intent.createChooser(iten, "Send image"));
Now save and run the project. You should be able to share the image from imageview1.
In the event of on button1 click, use an add source directly block and put following code in it:
Bitmap bm = ((android.graphics.drawable.BitmapDrawable) imageview1.getDrawable()).getBitmap();
try {
java.io.File file = new java.io.File(getExternalCacheDir() + "/image.jpg");
java.io.OutputStream out = new java.io.FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
} catch (Exception e) { showMessage(e.toString()); }
Intent iten = new Intent(android.content.Intent.ACTION_SEND);
iten.setType("*/*");
iten.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new java.io.File(getExternalCacheDir() + "/image.jpg")));
startActivity(Intent.createChooser(iten, "Send image"));
Now save and run the project. You should be able to share the image from imageview1.
http://www.sketchwarehelp.com/2018/02/share-image-from-imageview.html