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 = ((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.
How to share a image from web view
ReplyDeletehttps://clickfly.net/DussehraDrive
ReplyDeleteWie funktioniert das mit Sounds? Sounds aus der App in whatsapp Teilen?
ReplyDeleteError
ReplyDeleteError
ReplyDeleteError occurred when clicking button
ReplyDeletethank you
ReplyDeleteHelp me plz
DeleteHow to add download button on image view to save image in file manager
ReplyDelete