Right now I have:
Intent gallery = new Intent( ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI );
gallery.setDataAndType(Uri.parse("file:///sdcard/DCIM/"), "image/*");
startActivity(gallery);
What I'd like to accomplish is to only display images from the DCIM directory down, but instead I'm seeing every image on the device. I don't see any errors or warnings popping up for my process when I run this. I've tried splitting into setData and setType which predictably had the same effect.
Thanks in advance for any insight into what I'm missing.
Take a look at this answer by PiyushMishra
Built-in gallery in specific folder
Related
I use
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(getSomePath()+"temp.jpg")));
//intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, 0);
to get a picture and the saved picture returns as full-size.
But I want to get a limited picture, like 800*640, because on different devices I get different sizes, and I don't need that big picture.
I notice that there is a EXTRA_SIZE_LIMIT in MediaStore , but I can't find how to use it, what parameter should be set?
Answering my own question.
Finally I found that's because different manufacturers customize their Rom, including the Camera app, so the best way is not to call the default camera app, instead we can write a activity use hardware.camera to take picture. There are a lot of examples for this around the Internet too.
Unfortunately EXTRA_SIZE_LIMIT used for video limit in bytes.
I am trying to use Android gallery to pick image. Launching gallery is easy for that purpose
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);
However, I need to limit images that are shown in the gallery to specific path on device (i.e. to show images from single folder only). Is this possible to do and how?
Sorry, no this is not possible.
Also you are using this Intent protocol wrong. As per http://developer.android.com/reference/android/content/Intent.html#ACTION_PICK this protocol expects that you put the content: URI of the data set you want the picker to select from.
That said, you should consider ACTION_PICK deprecated. The modern action is ACTION_GET_CONTENT which is much better supported; you will find support of ACTION_PICK spotty and inconsistent. Unfortunately, ACTION_GET_CONTENT also does not let you specify a directory.
Why not ?
Intent galleryIntent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivity(galleryIntent)
Good luck with..
I searched the Internet for quite a while without finding a solution.
I want to let the user pick images of his gallery using an intent.
For this i use a GET_CONTENT intent:
Intent intentBrowseFiles = new Intent(Intent.ACTION_GET_CONTENT);
intentBrowseFiles.setType("image/*");
intentBrowseFiles.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intentBrowseFiles,1);
But this only works for one image. Is there any possibility to make it work for more than one, or do I have to rebuild my own gallery for this?
The documentation clearly says:
Output: The URI of the item that was picked. This must be a content: URI so that any receiver can access it. (emphasis mine)
So, no, there doesn't seem to be a way to use the default Intents to select multiple items. Having an "add more" button should be easier than developing your own gallery, though.
I want the user to be able to select from ALL images - those included with my app aswell as any they may have on their sdcard. For example, I have a .jpg file called cat.jpg in the data/com.mypackage/files folder, but it will not show in the list of images. This is the code I used, but it only displays images on the sdcard:
// Open up a gallery browser
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"),1);
I know that I could have two screens, one showing my images and another showing those from the sdcard, but I would rather have all of pictures in one gallery list.
Any ideas?
Thank you.
update:
Since no one has responsed, then maybe this type of task just can't be done. I cannot find any documentation one way or the other. If someone knows where the gallery view gets its data, please let me know (docs just says images - not the source of them). Or if it is not possible to combine all images from both the phone and the sdcard in one display, I would appreciate that response also.
Thanks again.
We can view an image with code:
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
File file = new File("/sdcard/test.jpg");
intent.setDataAndType(Uri.fromFile(file), "image/*");
startActivity(intent);
What if we have some images? How can we put the extras to let the viewer know we have
/sdcard/a.jpg, /sdcard/b.jpg, /sdcard/c.jpg ?
I hope to do this in a time because starting an activity is very expensive.
can any one help me? Thanks!
You can't.
The whole system of intents and uris is to either do an action on one item, or do an action on all items. See http://developer.android.com/reference/android/content/Intent.html and search for "content://contacts/people/1" and "content://contacts/people/" Have you tried looking for the intent that would let the viewer show all images in "/sdcard/". Even better is to plug into the content provider of that native viewer.
http://developer.android.com/reference/java/io/File.html#exists%28%29