把bitmap插入到相册和相机图库
来源:互联网 发布:无线网当前网络不可用 编辑:程序博客网 时间:2024/06/10 17:54
插入到相册:
File file = new File(filePath); try { MediaStore.Images.Media.insertImage(activity.getContentResolver(), file.getAbsolutePath(), fileName, null); } catch (FileNotFoundException e) { e.printStackTrace(); } // 最后通知图库更新 activity.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + Environment.getExternalStorageDirectory().getPath()))); Log.d("tag", "通知成功");
插入到相机图库:
String path="";String fileName="test.png"SAVE_PIC_PATH = Environment.getExternalStorageDirectory().getAbsolutePath(); SAVE_REAL_PATH = SAVE_PIC_PATH + "/DCIM/Camera/"; path = SAVE_REAL_PATH + path; File localFile = new File(path); if (!localFile.exists()) { localFile.mkdirs(); } File file = new File(path, fileName); if (!file.exists()) { try { file.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } try { BufferedOutputStream bf = new BufferedOutputStream(new FileOutputStream(file)); paramBitmap.compress(Bitmap.CompressFormat.JPEG, 100, bf); bf.flush(); bf.close(); } catch (IOException e) { e.printStackTrace(); } Intent localIntent = new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE"); localIntent.setData(Uri.fromFile(file)); activity.sendBroadcast(localIntent);
阅读全文
0 0
- 把bitmap插入到相册和相机图库
- android 把文件插入到系统图库
- UIPickerViewController 打开相机 图库 相册
- 把bitmap保存到手机相册
- Android把svg图片转为jpg保存到相册图库
- Android 跳转到系统相机和相册
- 调用系统相机和图库
- 调用系统图库和相机
- 调用相册和相机
- android相机和相册
- 调用相机和相册
- Android调用系统相机和相册添加图片到
- 保存图片到【相机胶卷】和【自定义相册】
- Android_通过Intent调用系统相机和相册回传bitmap
- Android保存Bitmap到本地图库
- 将Bitmap保存到相册
- Android 保存bitmap到相册
- 关于使用安卓系统自带的相机进行拍照,把照片存到系统图库gallery中
- jni小结
- HPE慧与(原惠普)12月10日Devops免费公开课报名--敏捷之旅2017 北京站:Devops 专场
- go语言使用sftp包上传文件和文件夹到远程服务器
- Aspose.Words 重要改变:Xamarin 和.NET Standard 2.0
- Javascript
- 把bitmap插入到相册和相机图库
- 概念-RPC(Remote Procedure Call)
- 【自定义View】一个完整的自定义View简介
- 网上找的浮点数表示为二进制的方法,IEEE754规则
- C# string类型和byte[]类型相互转换
- Web设计购物网站程序源码
- spark 数据倾斜问题
- 查找树的一点区分
- JVM中stackoverflowerror与outofmemoryerror区别