When picking a file from the Library, only photos are listed. Video files should also be shown.
Im Using this code
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),SELECT_PICTURE);
use following for pick both images and videos.
Intent mediaChooser =new Intent(Intent.ACTION_GET_CONTENT);
//comma-separated MIME types
mediaChooser.setType("video/*, images/*");
startActivityForResult(mediaChooser,IMAGE_PICK);
Related
Currently, I am using below code to fetch an image from gallery
Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
galleryIntent.setType("image/*");
startActivityForResult(galleryIntent, Constants.SELECT_GALLERY);
But the issue is that its also showing GIF file, when open gallery, I want only image files, I have also tried this
galleryIntent.setType("image/jpeg, image/png");
But the result is same. How could I achieve this?
Solution:
This solution is from my own project usage:
String[] mimeTypes = {"image/jpeg", "image/png"};
Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT)
.setType("image/*")
.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
then startActivityForResult(galleryIntent, Constants.SELECT_GALLERY);
The Intent.ACTION_GET_CONTENT and image/* asks android to get anything that can open it, i.e. gallery, and the Intent.EXTRA_MIME_TYPES retruns those intent only those MIME types to be selectable.
This will help.
I use
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, null), Photo.REQUEST_PICK_FROM_EXISTING);
Only images are getting displayed and with an option to use third party file manager apps which shows videos too. I want user to choose third party apps but choose only images. Is there any way to control it ?
Use the below code:
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, SELECT_PHOTO);
Hope this helps.
If we have to get the image file from device then we have to write following code:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Choose Picture"), 1);
But what we have to do if we don't want to choose only image and video files.
I want that the file chooser window should show all the files except image and video.
I am trying to reproduce some exceptions my android application is getting during my activity's Image Chooser intent:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), INTENT_REQUEST_GALLERY);
Does anyone know how I can reproduce the steps that return a picasa content provider uri like this:
content://com.google.android.gallery3d.provider/picasa/item/5893756913818770722
I want to open a images folder with android built-in gallery.
For example, I have a folder path that contains images, i want to open it with gallery.
I am using this code, it opens the gallery that contains no images.
Any idea?
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(folderImages)),"image/*");
startActivityForResult(intent, 1);
Maybe try this one:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, ""), 1)