Import the selected Images from the gallery to your app - android

I am using following code to select multiple images from the gallery
Intent intent = new Intent();
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select Picture"), 1);
This works fine and I can select multiple images from the gallery. But what I want to do now is to import all the selected images in our app and populate those images in the form of a ListView. Can anyone suggest anything that might help me. Thanks in advance.

After you copy the selected images, you will have to display them on a list view.
Some code example to import/copy the selected images can be found here :
http://viralpatel.net/blogs/pick-image-from-galary-android-app/
The best documentation of Android to display images in a list view is here : http://developer.android.com/training/displaying-bitmaps/display-bitmap.html .

Related

How to pick multiple images from gallery?

In my application I allow to user to select multiple images to create pdf.
Issue is user is not able to select more than 1 images. I tried a lot but didn't get any perfect solution which can help me.
There are lot many lib available but i don't want to use it due to some reason.
I am looking for solution with native only.
Please help me.
Simple by putting extra:
int RESULT_IMAGE_MULTIPLE = 1;
Intent intent = new Intent();
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"Select pictures"), RESULT_IMAGE_MULTIPLE);

How to load images from gallery "images"

I'm trying to load images from gallery using the following code
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE);
The code works fine, however by default it loads only the recent photos. I have to click the menu to go to the "images" that show all images. Is there a way for me to load the image so by default it shows all "images" instead of the recent photos. Thank you.

Xiaomi MI device not picking image from Gallery

I have a very weird issue. I am picking an image from a gallery the code is working properly on all the devices like Nokia 6 , One Plus X. When it
comes to xiaomi devices the image is not getting set on ImageView .
Can anyone help me out on how to fix this issue ?
I have to pick multiple images.
Code to pick image from gallery
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE);
Remove multiple images selection if you are selecting then you need to resolve it by Cursor in a new String array.
and also add these two lines in your code:
android:hardwareAccelerated="false"
android:largeHeap="true"

How to pick single and multiple images from gallery?

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

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

Categories

Resources