Question

In my application i collect some images form the device's gallery as files' names. I whant to display one of the images when ever application started. When i use the following code -

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
String imageFileName = imagesNamesArrayList.get(rndIndex);
Uri imageUri = Uri.parse("file://" + imageFileName);
intent.setDataAndType(imageUri, "image/*");
startActivity(intent);

I get the following error -

03-22 18:00:18.248: E/AndroidRuntime(12560): FATAL EXCEPTION: MediaFeed

03-22 18:00:18.248: E/AndroidRuntime(12560): java.lang.IllegalArgumentException: Found authority component in URI: file://mnt/sdcard/tapjoy/cache/images/placeholder.png

How it can be solved?

Was it helpful?

Solution

You're seeing the error because your URI is malformed; it looks like you're missing a forward slash. The two components of the URI are file:// and the path /mnt/sdcard/tapjoy/cache/images/placeholder.png so you should end up with:

file:///mnt/sdcard/tapjoy/cache/images/placeholder.png

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top