How to pick single and multiple images from gallery? - android

I want to pick single and multiple images from gallery, I have tried below code
Intent intent = new Intent();
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
but it allows only multiple images, I can't select single one. I want pick single as well as multiple images.

There is no any default way to pick multiple images from android Gallery. You have to make your own media picker for the same. Please refer following link to get source code for picking multiple media. here

Related

Android - how to open image in gallery with delete option

I use following code to open an image in the gallery:
public void onItemClicked(PictureItem item){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri imageUri = FileProvider.getUriForFile(getApplicationContext(), "myapp.fileprovider", new File(item.uri.getPath()));
intent.setDataAndType(imageUri, "image/*");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent);
}
This shows my photo in the gallery, but in a 'read-only' mode. I want to be able to delete the image from there, just as if I opened it directly in the gallery.
Which action do I have to use for that? I do not want to use pick, just normal view with the option to delete. I tried ACTION_EDIT but it's not supported (and not quite the right choice neither ...).
I use following code to open an image in the gallery
First, there are hundreds, if not thousands, of "gallery" apps available for Android.
Second, your code simply asks to view an image (with a broken Intent due to your wildcard MIME type). There is no requirement for the app that responds to be a "gallery" app.
I want to be able to delete the image from there, just as if I opened it directly in the gallery.
Then implement that yourself, in your own app, and get rid of the ACTION_VIEW Intent.
Which action do I have to use for that?
There is no Intent action that says "please display this image, but only if you are a gallery app, and, oh, by the way, you must offer a delete option", which appears to be what you want.

Add folder of images to Android app visible by intent

I want to add a folder of free images to my app, so that the user easily finds it with
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_OPEN_DOCUMENT);
startActivityForResult(Intent.createChooser(intent,
"Select image"), SELECT_IMAGE);
(Next step would be do let user click something to download another folder, perhaps at a cost.)
I only find ways to add images to the app so that direct links to the images can be shown in the app, but I didn't figure out how to let those image be part of the selection shown with the code above.

Ability to change the attributes of the default selector when uploading through android

We have a website where on mobile and specifically android devices when people want to change their "avatar" image the options that show up when we click on "upload" does not have the "Gallery". Instead it has "Documents" is there a way to define what to show and what not to show?
We are using PHP if that matters at all for development.
Please see below image.
well it depends on which intent you have used for upload button, in my opinion the most appropriate intent to call when you want user to select an image would be
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST);
it would make the gallery and other photo handling apps visible in the chooser dialog.
for more information you can go here
Hope it helps

File dialogue replacement?

I have a small app where some people can have a 1:1 chat with each other. Now I want to implement a possibility to share some files (images, sounds, whatever,...).
My problem: I need a possibility to let the user choose such a file. Since I did not find some kind of "file dialogue" for Android: what is the best way to do this?
I do not need a ready-to use solution but just some hints/ideas how this could be done out of an app.
Thanks!
You can have one Button in your screen and clicking on that button let user choose a file from gallary using below code,
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);//
startActivityForResult(Intent.createChooser(intent, "Select Picture"),SELECT_IMAGE);

How can I display all images - those included with the app and on the sdcard?

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.

Categories

Resources