首先您需要在glide中加载图像(因为您正在使用glide),然后您可以将其共享到任何地方,但图像将保存到存储中
从glide加载图像的代码(图像正在保存到存储器中,您可以稍后删除它)
Glide.with(getApplicationContext())
.load(imagelink) \\link of your image file (url)
.asBitmap().skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.NONE)
.into(new SimpleTarget<Bitmap>(250, 250) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "Hey view/download this image");
String path = MediaStore.Images.Media.insertImage(getContentResolver(), resource, "", null);
Uri screenshotUri = Uri.parse(path);
intent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
intent.setType("image/*");
startActivity(Intent.createChooser(intent, "Share image via..."));
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
Toast.makeText(getApplicationContext(), "Something went wrong", Toast.LENGTH_SHORT).show();
super.onLoadFailed(e, errorDrawable);
}
@Override
public void onLoadStarted(Drawable placeholder) {
Toast.makeText(getApplicationContext(), "Starting", Toast.LENGTH_SHORT).show();
super.onLoadStarted(placeholder);
}
});