Share an image from an ImageView

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 = (( 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"));

Now save and run the project. You should be able to share the image from imageview1.


Post a Comment

Popular posts from this blog

Simple car racing android game in Sketchware

Enable Fullscreen for Youtube videos in WebView

Creating a Drawing View in Sketchware

How to enable upload from webview in Sketchware?

List of Calendar Format symbols valid in Sketchware