Open image for sharing - android

I have Android Xamarin application with imageview
OnClik I lunch intent to preview image
File file = new File(photoPath);
Intent intent = new Intent(Intent.ActionView);
intent.SetDataAndType(Uri.FromFile(file), "image/*");
intent.SetFlags(ActivityFlags.NoHistory);
StartActivity(intent);
from apps I choose 'Gallery'
when the image is opend there are no sharing options
when I open image from device 'Gallery' has sharing options
Image is saved to SD card before preview.
what am I doing wrong ?

solution that worked for me
Intent intent = new Intent();
intent.PutExtra(Intent.ActionView, photoPath);
intent.SetType("image/*");
StartActivity(Intent.CreateChooser(intent, "Select Picture"));
now I get my image opend in gallery and I can use sharing options too

Do it using Intent.ACTION_SEND and you'll get that sharing option.
Also try with Intent.ACTION_GET_CONTENT.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), 1);

Related

How to pick only videos from gallery?

I want to be able to pick only videos from gallery but I only found tutorials that select images but I only want to be able to select videos.
Can anyone help?
For example, when you use an intent, you can set the type of your intent. Here I'm using "video/*" to get all videos of my device.
Intent galleryIntent = new Intent(Intent.ACTION_PICK);
galleryIntent.setType("video/*");
startActivity(galleryIntent);
Try this code..
protected int REQUEST_TAKE_GALLERY_VIDEO = 3;
Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Video"),REQUEST_TAKE_GALLERY_VIDEO);

how to select pdf file using intent and get that selected pdf file path in onActivityResult

I am trying to select pdf using intent and get that selected pdf file path I am not sure its right or wrong.
if not then how can I get pdf path in onActivityResult.
.
Intent intent = new Intent();
intent.setType("pdf/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select PDF"), PDF_PICKER_RESULTS);
using application/pdf line i can do this things.
Intent intent = new Intent();
intent.setType("application/pdf");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select PDF"), PDF_PICKER_RESULTS);

implement set as picture button in my app

I displayed images from webservice using json. Now how to provide user to make image as profile picture for whatsapp or contact photo etc., How to call that intent to open set picture as -> Set as -> showing multiple options -> Contact photo wallpaper, whatsapp profile photo etc.,?
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(Uri.parse(filename.getAbsolutePath()), "image/*");
intent.putExtra("jpg", "image/*");
startActivity(Intent.createChooser(intent, ("set as")));
use this code.
File externalFile=new File("filePath")
Uri sendUri = Uri.fromFile(externalFile)
Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(sendUri, "image/jpg");
intent.putExtra("mimeType", "image/jpg");
startActivityForResult(Intent.createChooser(intent, "Set As"), 200);

Pick images from specific directory

I'm getting Bitmaps using:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
startActivityForResult(intent, REQUEST_CODE_BACKGROUND);
How can I open Media Picker to get Bitmaps from specific directory?
Hope this can help you:
Bitmap bmp = BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/yourFolder/yourImg.jpg");

Android image picker for local files only

I'm using the built in Android image picker as follows:
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
m_activity.startActivityForResult(photoPickerIntent, PHOTO_PICKER_ID);
Is there any way to restrict this to show only locally available files. On my device it is currently picking up Picasa thumbnails and I'd like to exclude all images that are not actually present on the device.
Adding intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); will allow for local files only. It will exclude picasa images. Hope this helps.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
startActivityForResult(Intent.createChooser(intent,
"Complete action using"), PHOTO_PICKER_ID);
User this code to launch intent to get local image chooser.
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Complete action using"), PHOTO_PICKER_ID);

Categories

Resources