How can I add an image slider that becomes full screen when clicked?
I would like to be able to preview the images in full screen mode and be able to share it or zoom it. What are some ways that I can implement this?
Use this lib to zoom image and for sharing an image you can use share intent
Bitmap icon = mBitmap;
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));
Related
I am tring to share an image which i fetch from Json. After a number of attempts i finally concluded with this code. It works well till i open whatsapp and select the contact i want to share, the image doesnt load from there and when i click on submit, it says sharing failed.
Drawable drawable1 = imageViewPreview.getDrawable();
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.id.image_preview);
File file = new File(SlideshowDialogFragment.this.getCacheDir(), String.valueOf(largeIcon + ".png"));
// FileOutputStream fOut = new FileOutputStream(file);
// largeIcon.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
file.setReadable(true, false);
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
intent.setType("image/png");
startActivity(intent);
if i remove the comments
FileOutputStream fOut = new FileOutputStream(file);
will show error message and i have to add try/catch then, the app crashes saying Nullpoint exception
Try this code:
Bitmap bitmap = mBitmap;
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory() + File.separator + "photo.jpg");
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/photo.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));
I am able to share image and multiple text using the following code:
Bitmap icon = BitmapFactory.decodeResource(getResources(),
R.mipmap.ic_launcher);
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("*/*");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory()
+ File.separator + "temporary_file.jpg");
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
share.putExtra(android.content.Intent.EXTRA_SUBJECT, "this is subject");
share.putExtra(Intent.EXTRA_TEXT, "HeadLine.\nIntroText");
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file:///sdcard/temporary_file.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));
I tested it in whatsapp share and it is working. Here is the current share output:
-->> Image display
-->> Subject display
-->> Extra text display
But I am using custom formatting and it is not working. Here is the custom formatting:
-->> Image display in left side with 20*20 -->> Subject display in right side
-->> Extra text display in right side
Can this be done?
I've used the following code to save an image file to the external storage
drawView.setDrawingCacheEnabled(true);
String img = MediaStore.Images.Media.insertImage(getContentResolver(),drawView.getDrawingCache(),UUID.randomUUID().toString()+".jpeg", "doodle");
I want to return this saved file to Whatsapp using an intent. Can somebody please help me out with the code? I'm new to android and would really appreciate it! Thanks :)
Try this code
Bitmap icon = mBitmap;
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));
I am trying to share an image and text.
When I'm doing this:
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
screenshot.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory()
+ File.separator + "temporary_file.jpg");
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file:///sdcard/temporary_file.jpg"));
share.putExtra(android.content.Intent.EXTRA_TEXT, textToShare);
startActivityForResult(Intent.createChooser(share, "Share Image"),
FROM_SHARE);
It works greate on all apps (that was choosen from the popup dialog like Gmail) except for facebook, facebook takes only the image and not the text.
Is there a whay to pass an extra text with an image to the facebook app?
Thanks!
There is a bug in FACEBOOK I have the same problem If you really want to do that anyhow you need to use facebook SDK for that and use Facebook ShareDialog.
Creating an a app, where I store bunch of photos in the drawable folder, When the user longpress on a photo brings up a menu, one of the options is to share.I can get the contextmenu up, but have no clue how to share from the grid menu.
I also have the expand it is bring up single image in own view and can share from there.
But when the user selects the Image from the gridview I have no Idea how to share that one.
this is the method i call when user selects share option
public Intent intentShare() {
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://your.package.here/drawable/"+share.putExtra("id", lastPosition)));
startActivity(Intent.createChooser(share, "Share Image"));
return share;
}
I have seen this possible option/solution on a couple of other questions
Bitmap icon = mBitmap;
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");
try {
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
} catch (IOException e) {
e.printStackTrace();
}
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));
But I have no idea how to initialize mBitmap if that works ?
The entire code can be found here: http://pastie.org/private/gdpyn2t55h0gp1vp1kika
You can convert the Bitmap from resource using code like this:
Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), mThumbIds[lastPosition]);
now you can share it as you share in Expanded view.