Android在默认图库查看器中显示图像
问题描述:
我正在使用AsyncTask将一些图像加载到我的活动中,作为可点击的图像.单击时,我需要在android的默认图像查看器中打开该图像.我是android新手.任何人都可以帮忙.我的代码看起来像
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");
}
});
请帮助我.
答
图库应用程序不接受图像的URL作为Intent的一部分.您需要先保存图像.然后,您可以使用以下内容启动默认的图像查看器:
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);