4

I want to show a photo in android gallery, and be able to slide throw the others photos on that folder.

Intent intent = new Intent(Intent.ACTION_VIEW);
File f = new File(path);
intent.setDataAndType(Uri.parse("file://" + f.getAbsolutePath()), "image/*");
mContext.startActivity(intent);

thats how i am doing it now, but wont let me slide throw the rest of the images in the folder. i tried:

How to open one particular folder from gallery in android?

Built-in gallery in specific folder

Gallery with folder filter

Without any luck. i would be really happy if someone have the solution. Thanks!

Community
  • 1
  • 1
Nero
  • 194
  • 1
  • 1
  • 11

3 Answers3

10

Try This

Intent i=new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(new File(path)), "image/*");  
startActivity(i);

See these Links

How can I use Intent.ACTION_VIEW to view the contents of a folder?

Android ACTION_VIEW Multiple Images

Java and Android: How to open several files with an Intent?

if this solves your problem. Also check

https://www.google.co.in/?gfe_rd=cr&ei=c5n9U6ruE7DO8gfXz4G4BA&gws_rd=ssl#q=view+like+gallery

also check Gallery widget

Community
  • 1
  • 1
Nitin
  • 1,966
  • 4
  • 22
  • 53
  • same result, it shows me the image but wont let me slide between the other images of the folder :C – Nero Aug 25 '14 at 13:16
  • just check if you are using the correct path.just print the Path using Log.e("My Path",path);. The code above is working. Hope this helps you :) – Nitin Aug 26 '14 at 05:14
  • the path is ok, it shows me the image, dont let me slide sadly XD – Nero Aug 26 '14 at 14:18
  • 1
    I think its just not posible to do what i want to do, like some ppl say it depends on what the image viewer do with the uri i guess i will make my own image viewer so i can do whatever i want with it i will make yours as answer b/c you link to the its not posible post so thank you! :D – Nero Aug 27 '14 at 15:03
1

This question is from five years ago, However I want to give an answer that worked for me instead of the correct answer.

In order to show the photo and slide through the others photos, we need to give to the intent not the file uri but the media uri.

public void ShowPhoto(File imageFile) {

    String mediaId = "";

    String[] projection = new String[] {
            MediaStore.Images.Media._ID,
            MediaStore.Images.Media.DISPLAY_NAME
    };

    Cursor cursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
            projection, null, null, null);

    while (cursor != null && cursor.moveToNext()) {
        String name = cursor.getString((cursor.getColumnIndex(MediaStore.Images.ImageColumns.DISPLAY_NAME)));
        if(name.equals(imageFile.getName())){
            mediaId = cursor.getString((cursor.getColumnIndex(MediaStore.Images.ImageColumns._ID)));
            break;
        }
    }

    Uri mediaUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;

    if(!mediaId.equals("")){
        mediaUri = mediaUri.buildUpon()
                .authority("media")
                .appendPath(mediaId)
                .build();
    }

    Log.d("TagInfo","Uri:  "+mediaUri);

    Intent intent = new Intent(Intent.ACTION_VIEW, mediaUri);
    startActivity(intent);

}
-1

Try this way,hope this will help you to solve your problem.

final int OPEN_GALLERY = 1
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, ""), OPEN_GALLERY);
Haresh Chhelana
  • 24,720
  • 5
  • 57
  • 67
  • nope this wont do, i am already showing thumbnails of the photos in the folder i need to open them in fullscreen and slide throw them. Thanks anyway! – Nero Aug 25 '14 at 13:18