Pick images from specific directory - android

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

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);

Open image for sharing

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);

Get Audio File Uri From File Chooser

I need help creating a file chooser that gets the path of the audio file selected as a Uri.
This is what I'm currently using as my file chooser:
public void selectedAudio() {
Intent intent = new Intent();
intent.setType("audio/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
startActivityForResult(Intent.createChooser(intent, "Choose Sound File"), 1);
}
But I have no idea how to get the path of the file selected.
In the onActivityResult() method call the passed Intent's getData() method and then getPath:
String filePath = data.getData().getPath();

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