How to Share an image from imageview to any app.

1) Create a new sketchware project or use an existing project.

2) For sharing images from imageview1 , set a button as button1 to initiate sharing.
3) In button1 onClick event add a ASD block and paste the below code:-
Bitmap bm = (( imageview1.getDrawable()).getBitmap();
try { file = new + “/image.jpg”); out = new;
bm.compress(Bitmap.CompressFormat.JPEG, 100, out);
} catch (Exception e) { showMessage(e.toString()); }
Intent iten = new Intent(android.content.Intent.ACTION_SEND);
iten.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new + “/image.jpg”)));
startActivity(Intent.createChooser(iten, “Send image”));

If the above code crashes consider adding WRITE EXTERNAL STORAGE by adding a more block as nothing and a blank write string to file path block.

Leave a Comment