[英]Having trouble saving image to gallery in Android
我正在编写一个Android应用,并且试图将图像保存到手机的图像库中。 当我逐步执行此代码时,它似乎运行良好,并且未引发任何异常。 我只是在图库中看不到下载的图像,而在模拟器上也找不到它们。
为什么使用下面的代码下载的图像不会显示在手机的图库中?
URL imageURL = new URL(photoRequestUrl);
Bitmap imageBitmap = BitmapFactory.decodeStream(imageURL.openStream());
//getContext().
MediaStore.Images.Media.insertImage(getContext().getContentResolver(), imageBitmap, "title" , "description");
也许您重新启动手机会在图库中看到图片。 将一些内容写入存储后,尝试写入此行。
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory())));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.