有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java拍摄照片,然后命名

我想用standart系统服务拍照

Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);

之后,我想给它一个自定义名称和目录或路径(在我用相机活动拍照后,应该在另一个活动中发生)

问题是,如果我创建了一个包含所有属性(名称、路径)的文件,并将其交给了intent,那么在拍摄完照片后,我无法在活动中执行此操作,而是需要在打开intent(拍摄照片)之前确定其属性。 (正如谷歌文章所建议的:https://developer.安卓.com/training/camera/photobasics#TaskPath

我是否应该获取完整大小的位图,然后打开其他活动,然后保存它并确定其属性

有没有一种方法可以做到这一点,就像文章中建议的那样,但却有另一种方法呢?(以后创建文件)

如果你有任何想法,请告诉我

我接受任何帮助。 谢谢大家!


共 (1) 个答案

  1. # 1 楼答案

    I want to take a picture with the standart system service

    你的代码正在启动数百个可能的摄像头应用中的任意一个。特定的应用程序可能是由设备制造商预装的,也可能是用户安装的应用程序

    The problem is that if I create a file with all the attributes (name, path) and give it to the intent I cant do it in the activity after having taken the photo instead I would need to determine its attributes before I open the Intent(take the photo).

    Should I just get the fullsize Bitmap then open the other activity and then save it and determine its attributes?

    没有办法让ACTION_IMAGE_CAPTURE直接给你一个“全尺寸位图”。你可以得到一张缩略图大小的Bitmap,或者让它在你选择的位置上写一张全尺寸的照片

    Is there a way to do it as suggested in the article but somehow the other way around?(create the File afterwards)

    没有。但是,没有什么能阻止你通过活动中的文件打开照片,然后修改照片并将其写出来。您可以覆盖原始文件,也可以写入到某个新位置

    因此,例如,如果您担心在您的活动完成之前,您不希望照片位于用户可访问的位置,那么您可以将指向getCacheDir()中私有位置的Uri传递给ACTION_IMAGE_CAPTURE,然后让您的活动将照片的最终版本写入external storage上的文件