3

I need to open a specific image in Android Gallery, but I tried some codes with no success. This is my code:

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse( "file:///Download/screenshot.jpg"), "image/*");
startActivity(intent);

It seems the Android Gallery is open but with no image, it show a black screen.

I'm trying my app in a Samsung Galaxy Nexus with ICS 4.0

Hope anyone can help me.

Thanks, Víctor.

lokoko
  • 5,785
  • 5
  • 35
  • 68
vicxros
  • 31
  • 1
  • 2
  • How does the file get there? it could be a permission problem, when the file is written it depends wether the MODE_WORLD_READABLE flag was set during writing. – Ian Warwick May 04 '12 at 16:04
  • There is a complete answer on [this](http://stackoverflow.com/questions/2169649/open-an-image-in-androids-built-in-gallery-app-programmatically) page. – se_bastiaan May 04 '12 at 16:10
  • Is the file path correct? Shouldn't there be sdcard in there somewhere? – FabianCook May 04 '12 at 16:20
  • 1
    Uri.parse( "file://sdcard/Download/screenshot.jpg") ?? – FabianCook May 04 '12 at 16:20
  • First at all, thank you every one you have answer my question. And special thanks to SmartLemon, because I only added "scard" to my path file and... It worked! – vicxros May 06 '12 at 19:01

0 Answers0