美文网首页
记录一下 调用系统相册后,刷新相册方法

记录一下 调用系统相册后,刷新相册方法

作者: Thor_果冻 | 来源:发表于2018-12-29 15:23 被阅读0次

三种方法,刷新 Android 的 MediaStore!让你保存的图片立即出现在相册里!

            //拍照完成
            //第一种方法
//            val absolutePath = mMediaStoreUtils.getCurrentAbsolutePath()
//            val fileName = File(absolutePath).name
//            MediaStore.Images.Media.insertImage(
//                contentResolver,
//                absolutePath, fileName,
//                fileName)

            //第二种跟新方法
            //val currentUri = mMediaStoreUtils.getCurrentUri()
            //这个广播的目的就是更新图库,发了这个广播进入相册就可以找到保存的图片了
            //sendBroadcast(Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, currentUri!!))

            //第三种更新方法
            MediaScannerConnection.scanFile(
                this,
                arrayOf(mMediaStoreUtils.getCurrentAbsolutePath()),
                arrayOf("image/jpeg")
            ) { path, uri ->
                
            }

相关文章

网友评论

      本文标题:记录一下 调用系统相册后,刷新相册方法

      本文链接:https://www.haomeiwen.com/subject/vaxplqtx.html