Search code examples
androidandroid-intentuniversal-image-loader

Android Universal Image Loader Intent


I am using Universal image Loader to bind images to ImageView inside my listview. These images are being fetched from online url at time of binding asynchronously. Now i want to open the image on click of ImageView. How can I call intent that will handle displaying the Image. I'd like to display the image loaded using Universal image Loader in user's default image viewer app. I have the below code that opens any image on the device :

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri imgUri = Uri.parse("file://" + yourfilepath);
intent.setDataAndType(imgUri, "image/*");
startActivity(intent);

Solution

  • Gallery application does not accept URL for an image as part of the Intent. You need to save the image first. Then you can launch the default image viewer with something like this:

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