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.
Related
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.
while sharing image via android share intent hangout shows old image inside image preview screen which appears before sending image,but whatsapp and facebook shows cuurently selected image itself,
even it shows wrong image in preview ater clicking send, in chat correct image will only be displayed.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/png");
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
startActivity(Intent.createChooser(intent, "Share news via.."));
can any one help with this issue
I found reason behind this issue, i was giving same name everytime to store and share the image, by defalut hangout image send preview screen will display old image , if image name is same. so changing image name everytime will fix the issue.
I'm going to develop a simple app to list .jpg files and after a click call an Intent.ACTION_VIEW, below the code:
File imageFile = new File(filename);
Intent i = new Intent();
i.setAction(android.content.Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(imageFile), "image/jpeg");
startActivity(i);
The intent works properly, in fact in app I receive the message to select an app to show the selected image. But I noticed that after the choice, for example with Google Photos, not all function are enabled. For example the share function is not visible, has someone already noticed this behavior?
Some other details; if I choose Google Photos I only have the "Info" and "Guide and Feedback" options. If I choose gallery app (I have a Samsung Ace 3) I have only "Info" and "Set as wallpaper" options.
Note: if I open the same image directly from Google Photos all functions are enabled...
The ACTION_VIEW intent calls another application to view the content that you present, in your case a JPEG image. If there is more than on application that can handle that Intent, Android lets the user choose an app to display the image. Once the application receives the Intent, it is up to that application to display the content how it sees fit.
Basically, you have no control over what functions are available with Intent.ACTION_VIEW. If you want more control, you can create your own Activity in which you can view the image and provide whatever functions you would like.
I am developing an android app. When I capture an image using the code
Intent intent = new Intent(MediaStore.ActionImageCapture)
it will be stored in my sdcard as well as it will be displayed in the ImageView. Next, on button ‘Crop Picture’ click event, it should open the captured image as a new intent with the crop feature.
I've code to open the Gallery and select the captured image with the crop feature, but I don’t want the Gallery to get opened, instead I want the captured image in new intent with crop features.
Could anyone please assist?
In this case What you should do is, when it goes to next activity, save the image in local device, and put the image location as a intent value. Then when the new activity start, onCreate method, get the image location from intent values and load the image from the saved location. then delete the saved image.
If you can wait for few hours, I can put the code here.Feel free to ask anything until you get what you want.
Cheers!!
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.