Xiaomi MI device not picking image from Gallery - android

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"

Related

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.

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

Android Marshmallow 6.0, opening gallery via intent says No apps to perform the action

I am trying to open gallery on Nexus 7 with Android 6.0. It does not have in built gallery, but it does have the Google Photos app.
I am using the following code to open the gallery :
Intent i = new intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
// Always show the chooser (if there are multiple options available)
startActivityForResult(Intent.createChooser(i, "Select Picture"), PICK_IMAGE_REQUEST);
The above code works well in all the versions below 6.0. And Please note that I am already using RUN TIME PERMISSIONS for accessing gallery and have given the permission to access gallery / or externa storage.
Now when the code is executed, I get a transparent screen with heading "Select Picture" and in the middle a text No Apps can perform this action.
Now what do I do to pick or choose image and use in my app.
Any help is appreciated.
Thanks
I am using the following code to open the gallery
That code has nothing to do with a "gallery". That code is requesting to pick a piece of content from a particular collection of content. There may be zero, one, or several activities on the device that offer to support that Intent structure.
The above code works well in all the versions below 6.0
Only on devices that happen to have one or more activities that satisfies that Intent structure.
Now what do I do to pick or choose image and use in my app.
Intent i = new intent(Intent.ACTION_GET_CONTENT).setType("image/*");
// use PackageManager to see if there is anything that supports this
// Intent structure, or just blindly make the following call and handle
// the ActivityNotFoundException
startActivityForResult(i, PICK_IMAGE_REQUEST);
I am using this code , so that only gallery opens and not any other option to pick image
There is nothing in your code that limits it to just a "gallery".
Not allowed to comment because I don't have enough points. But here's just a suggestion, how about if you just passed the intent directly? Like this:
startActivityForResult(i, PICK_IMAGE_REQUEST);
Use this line of code rather than what you have done
Intent i = new intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, PICK_IMAGE_REQUEST);

How to pick images from Gallery instead of Photos in android?

I am using the following code to pick images.
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
photoPickerIntent.setData(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(Intent.createChooser(photoPickerIntent, getActivity().getResources().getString(R.string.select_picture)), 1);
Its working fine but it only let me to choose images from default Photos application. I want to pick images from "Gallery" application even in today's latest devices. I don't know how WhatsApp is doing this even for Lollipop.
I am using This code in my app and it works fine for me..
intent = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
intent.setType("image/* video/*");
startActivityForResult(intent, 3);

Import the selected Images from the gallery to your app

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 .

Categories

Resources