Android Gallery App - unable to select image due to no input - android

I am currently working on an application that lets users upload pictures by selecting them in the android gallery. This seems to work across most android phones however there are some issues with certain ones. On an LG Optimus Elite when the gallery is loaded to select the image it does not accept any touch. I can see the pictures and gallery however I cannot not select anything. It is almost as if it is frozen. There is nothing I can do at this point, not even press go back button.
Here is my code that launches the gallery:
Intent i = new Intent(Intent.ACTION_GET_CONTENT, null);
i.setType("image/*");
i.putExtra("return-data", true);
i.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
startActivityForResult(i, REQUEST_GALLERY_PICTURE);
Any input would be greatly appreciated.
Thank You

Use this
to open gallery
Intent i = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(i, RESULT_LOAD_IMAGE);

Related

Opening image in Gallery app programatically shows low resolution

I download and save an image on button click in my app. This works fine. If I view this image via the Gallery app (or any other way) it looks fine.
However, if I try to open the image with:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(imageFile), "image/*");
startActivity(intent);
It prompts me what app I want to open the file with (Gallery or Photos). If I select Gallery, the image opens but is very low resolution. As the photo contains a lot of text, it makes it so you can't zoom in and read. If I select "Photos", it looks fine.
Is there anything I can do to make it work fine in Gallery?
So I was saving the image with no extension. As it was opening in Gallery I figured it knew it was an image, but as soon as I added ".jpeg" to the file name, it showed in correct resolution. Strange bug, figured I'd update just in case someone else was hoping to find an answer here at some point.

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);

Galaxy nexus Intent.ACTION_PICK bug on Jelly Bean (4.1.1)

I've found a very frustrating bug on galaxy nexus. I start az ACTION_PICK activity to select image from, after starting it, the device shows the gallery, and immediately return and call onActivityResult, so I can't pick an image. It's only on galaxy nexus after update to Jelly Bean.
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(photoPickerIntent, RequestCodeCollection.GALLERY_IMAGE_SELECT);
I tested image picking with Instagram, and it worked well. What could be the trick?
UPDATE
I removed all code from onActivityResult() and I tried to remove overriding onActivityResult(). It not works. I checked how Instagram works. They use an ACTION_GET_CONTENT and a chooser. To create chooser is very important, because in this way user can't select a default source. If I don't create a chooser for every picking, I can select default source (like gallery, filemanager etc.), and after selecting the default the problem comes back.
Intent photoPickerIntent = new Intent(Intent. ACTION_GET_CONTENT , android.provider.MediaStore.Images.Media. EXTERNAL_CONTENT_URI);
photoPickerIntent.setType( "image/*" );
startActivityForResult(Intent. createChooser(photoPickerIntent, "Select Picture"),RequestCodeCollection. GALLERY_IMAGE_SELECT);
I removed all code from onActivityResult() and I tried to remove overriding onActivityResult(). It not works. I checked how Instagram works. They use an ACTION_GET_CONTENT and a chooser. To create chooser is very important, because in this way user can't select a default source. If I don't create a chooser for every picking, I can select default source (like gallery, filemanager etc.), and after selecting the default the problem comes back.
Intent photoPickerIntent = new Intent(Intent. ACTION_GET_CONTENT , android.provider.MediaStore.Images.Media. EXTERNAL_CONTENT_URI);
photoPickerIntent.setType( "image/*" );
startActivityForResult(Intent. createChooser(photoPickerIntent, "Select Picture"),RequestCodeCollection. GALLERY_IMAGE_SELECT);

How to speed up image viewing with android "Cooliris" gallery?

I'm running 2.3 on a Nexus S (but writing code against 2.2), and it takes forever for an image to display in the default cooliris gallery. This is how I am attempting to display an image:
Uri imageIdentifier = getImageUriOnFilesystem();
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(imageIdentifier, "image/jpeg");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Activity.this.startActivity(intent);
In the end, it takes 5-10 seconds for the gallery to go from a black screen to showing my image which is absurdly long and makes me think I'm doing something wrong. Is there a better way to display an image in the gallery without requiring a different gallery be installed?
You can add new images to the media index as you acquire them, which may may reduce the startup time of the gallery application.
Intent i = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
i.setData(imageIdentifier));
sendBroadcast(i);

Why it's so hard taking photos normally on different Android phones?

I made a program whose major function is use API to take photos and store them in the path I gave.
But things don't come out right on different phones comparing to that when I tested on the emulator or phone with Google's origin ROM.
Theoretically. If I gave a path to the Intent, the photo shouldn't appear in the phone's default gallery, but on MOTO Defy the photos were stored in both my path and default image directory. And on Samsung, my app crashes silently when return from the camera Intent. And only on some phones I can bring up menu by pressing the menu button in the Camera Activity. And even some of them saves photo as the size I set in the Camera Activity's setting menu.
I think this is because the manufacturers customized the ROM on their phones so the Camera Activity acts differently.
Anyone know how to avoid this situation? Or is there any other way to take photos not by the intent "android.media.action.IMAGE_CAPTURE" ?
The following is the code how I take photos.
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(getpath()+"_.jpg")));
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, 0);
The way that #balban shah offered worked all the same when I tried.
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.
try to use this code keep other setting same for photo capture
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(origImageFile));
startActivityForResult(cameraIntent, 0);

Categories

Resources