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

前端之家收集整理的这篇文章主要介绍了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.

原文链接:https://www.f2er.com/android/531472.html

猜你在找的Android相关文章