Cannot Show images with gallery app in android - android

I want open my images with gallery app but show this error
Cannot generate thumbnail
my code:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(Environment.getExternalStorageDirectory().getPath()+"/Connection/Picture/"+listItems.get(position)), "image/*");
startActivity(intent);
Is there another way to show image with default android app?
Notice:
1.when I use a file manager to open it , it open successfully
2.when I use my app to open image ,if I choose another app to open it,it open successfully
3."listItems.get(position)" is imagename forexample "2361386837.jpg"
Can You help me?

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.

while sharing image via share intent hangout shows old image inside image preview screen in android

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.

How to open particular image in gallery in android

I am using the following code to open android gallery when an image is clicked in my app
Intent intent = new Intent (Intent.AUri.parse( "content://media/internal/images/media" ));
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
mActivity.startActivity(intent);
how can i modify my code to open a particular image directory or a particular image
According to me you should try this.
In your MainActivity introduce a method to create intend for that
and use syntax
intent.setComponent(new ComponentName("com.example.administrator.YOUR GALLERY APP NAME","com.example.administrator.YOUR APP.MainActivity"));
where com.example.administration is the initial name of your package

How to open image with uri like "content://" in default gallery app?

In my app I select an image from gallery. After, when the user click on it, I want to open the image with an app that handle images.
In android kitkat 4.4 I have a "content://" uri. When I try this code:
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
intent.setDataAndType(uri,"image/*");
startActivity(intent);
The gallery app doesn't show me the image but a blank screen with an error message.
How can I open this kind of Uri with an intent?

Open Gallery in a Specific Directory

I'm trying to open all the photos taken with my app using the native Gallery.
Here is my code:
Intent intentBrowseFiles = new Intent(Intent.ACTION_VIEW);
intentBrowseFiles.setType("image/*");
Uri uri = Uri.parse(Environment.getExternalStorageDirectory() + "/DCIM/MyApp");
intentBrowseFiles.setData(uri);
intentBrowseFiles.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentBrowseFiles);
If I don't set the setData the gallery opens, but in the root, if I set, my app crashes.
Is there a way to open it in the Gallery in a specific directory?
Anyway, thank you!

Categories

Resources