android-如何将图片保存到文件?

我正在尝试使用将要拍照的标准Intent,然后允许批准或重拍.然后,我想将图片保存到文件中.

这是我正在使用的意图:

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );

startActivityForResult( intent,22 );

documentation说:

The caller may pass an extra EXTRA_OUTPUT to control where this
image will be written. If the EXTRA_OUTPUT is not present,then a
small sized image is returned as a Bitmap object in the extra field. If
the EXTRA_OUTPUT is present,then the full-sized image will be
written to the Uri value of EXTRA_OUTPUT.

我没有传递额外的输出,我希望在传递给onActivityResult()的Intent的额外字段中获得一个Bitmap对象(针对此请求).那么,您在哪里/如何提取呢? Intent有一个getExtras(),但是它返回一个Bundle,而Bundle想要一个键串来给你一些东西.

您在提取位图的意图上调用了什么?

最佳答案
尝试调用getExtras().get(“ data”)并将结果转换为位图.

See here for an example.

相关文章

AdvserView.java package com.earen.viewflipper; import an...
ImageView的scaleType的属性有好几种,分别是matrix(默认)...
文章浏览阅读8.8k次,点赞9次,收藏20次。本文操作环境:win1...
文章浏览阅读1.2w次,点赞15次,收藏69次。实现目的:由main...
文章浏览阅读3.8w次。前言:最近在找Android上的全局代理软件...
文章浏览阅读2.5w次,点赞17次,收藏6次。创建项目后,运行项...