Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: showing image in build-in gallery

I'm trying to open a picture in the build-in gallery, but it dosen't show up. I logged the URI to be

06-08 15:53:02.232: D/URI(3231): file:///mnt/sdcard/com.jesper.indkoeb/nm-image.jpg

which is the right place

                @Override
                public void onClick(View v) {
                    Intent intent = new Intent();  
                    intent.setAction(android.content.Intent.ACTION_VIEW);  
                    File file = new File(uri.get(position));
                    Log.d("URI",uri.get(position));
                    intent.setDataAndType(Uri.fromFile(file), "image/*");  
                    context.startActivity(intent);

                }

            });
like image 767
gedemagt Avatar asked Jan 17 '23 11:01

gedemagt


1 Answers

Following Snippet will help you.

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("file:///mnt/sdcard/image/Apples.jpg"),"image/*");
startActivity(intent);
like image 195
Vipul Avatar answered Jan 25 '23 13:01

Vipul