-1
我有一个gridview,单击gridview中的任何图像展开它到一个更大的图像视图,在这个图像视图我可以左右滑动来改变我的图像,我已经添加了一个方法,可以让我分享图像到其他应用程序,如脸书watsapp等,但该方法似乎不太正确,我无法找出我的错误。它打开弹出窗口显示共享图像的选项,但是当我选择任何选项发送图像它说,无法加载图像。共享内容
看一看我的代码:
else {
if (e2.getY() - e1.getY() > SWIPE_MIN_DISTANCE
&& Math.abs(velocityY) > SWIPE_THRESHOLD_VELOCITY) {
URL url2 = new URL((thumb[j]));
Bitmap bimage = BitmapFactory.decodeStream(url2
.openConnection().getInputStream());
shareImage();
Toast.makeText(getApplicationContext(),
"Saving to Favorites", Toast.LENGTH_LONG)
.show();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
}
private void shareImage() {
Intent share = new Intent(Intent.ACTION_SEND);
// If you want to share a png image only, you can do:
// setType("image/png"); OR for jpeg: setType("image/jpeg");
share.setType("image/*");
// Make sure you put example png image named myImage.png in your
// directory
String bimage = Environment.getExternalStorageDirectory()
+ thumb[j];
File imageFileToShare = new File(bimage);
Uri uri = Uri.fromFile(imageFileToShare);
share.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(share, "Share Image!"));
}
}
而拇指具有图像的所有的资源ID阵列,“J”是谁的价值开始为0
使用的INT启动代码的手势。
我准备好分享我的完整代码,以便更好地理解。
任何帮助将不胜感激。
你确定你在bimage中有东西吗? – Pavya
@ user3676184我没有得到你的问题,但是,是的,左右滑动可以改变我的图像视图中的图像,这工作正常,现在只需要共享图像视图中的任何图像。 –
http://stackoverflow.com/questions/7661875/how-to-use-share-image-using-sharing-intent-to-share-images-in-android检查这个链接 – Pavya