解决Android拍照保存在系统相册不显示的问题

本文介绍了Android拍照后图片无法在系统相册显示的问题及其解决方案。通过一句代码实现图片插入系统相册,并提供指定保存图片名称的方法。此外,还强调了在插入后发送广播以确保图库更新的重要性。
摘要由CSDN通过智能技术生成
               

可能大家都知道我们保存相册到Android手机的时候,然后去打开系统图库找不到我们想要的那张图片,那是因为我们插入的图片还没有更新的缘故,先讲解下插入系统图库的方法吧,很简单,一句代码就能实现

MediaStore.Images.Media.insertImage(getContentResolver(), mBitmap, "", "");
通过上面的那句代码就能插入到系统图库,这时候有一个问题,就是我们不能指定插入照片的名字,而是系统给了我们一个当前时间的毫秒数为名字,有一个问题郁闷了很久,我还是先把insertImage的源码贴出来吧

 /**             * Insert an image and create a thumbnail for it.             *             * @param cr The content resolver to use             * @param source The stream to use for the image             * @param title The name of the image             * @param description The description of the image             * @return The URL to the newly created image, or <code>null</code> if the image failed to be stored             *              for any reason.             */            public static final String insertImage(ContentResolver cr, Bitmap source,                                                   String title, String description) {                ContentValues values = new ContentValues();                values.put(Images.Media.TITLE, title);                values.put(Images.Media.DESCRIPTION, description);                values.put(Images.Media.MIME_TYPE, "image/jpeg");                Uri url = null;                String stringUrl = null;    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值