1

I am loading some images into my activity using an AsyncTask as clickable images. On click I need to open that image in the default image viewer of the android. I am new to android. Can any one please help. My code looks like

ImageView image = new ImageView(this);
String ed="http://www.domain.com/image.jpg";
image.setTag(ed);
DownloadImagesTask td=new DownloadImagesTask(this);
td.execute(image);

image.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View v) {
         Log.v("TAGG","sdsd"); 
      }
});

Please help me.

Chintan Rathod
  • 25,864
  • 13
  • 83
  • 93
ramesh
  • 4,008
  • 13
  • 72
  • 117

1 Answers1

4

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/test.jpg"), "image/*");
startActivity(intent);
Caner
  • 57,267
  • 35
  • 174
  • 180
  • thanks for your reply .. but I cant save the image to the sd card.. Is there any way to show the image in a separate activity on click ? – ramesh Jul 24 '13 at 10:50
  • I think that is not possible because gallery application does not accept URL for an image. – Caner Jul 24 '13 at 10:53
  • yea.. its ok I mean create a new activity in my application and load my image in a imageview. Is it possible ? Can we zoom image with in that activity ? like in Facebook app ? – ramesh Jul 24 '13 at 11:01
  • yes it should be possible like that, check this example: http://stackoverflow.com/questions/6650398/android-imageview-zoom-in-and-zoom-out – Caner Jul 24 '13 at 11:13