android - 打开带有缩略图图标的相机应用程序

标签 android camera gallery

我想启动右下角带有缩略图图标的 Android 内置相机应用程序。这是我打开相机应用程序的代码。

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);

我想我需要输入 Intent 数据才能做到这一点。我期待着您的帮助。

谢谢。

最佳答案

只需创建一个图像按钮,或按钮或您真正想要的任何东西。

在 onclick 事件中添加如下内容:

    String saveFileName= Environment.getExternalStorageDirectory() + "/test.png";

    // BUILT IN CAMERA 
    Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); 
    camera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(saveFileName) );   
    this.startActivityForResult(camera, 1);

确保您设置了必要的权限。就像保存到 SDCard。

你非常接近,你不需要设置那些标志。理想情况下,您应该指定保存图像的位置。 如果您想知道如何制作按钮 take a look here

关于android - 打开带有缩略图图标的相机应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12407073/

相关文章:

android - 错误 : Multiple substitutions specified in non-positional format; did you mean to add the formatted ="false" attribute?

java - 如何使用字符串的内容命名调用方法

android - 在不写入文件的情况下将视频录制到字节数组

安卓视频库

css - 将文本定位在画廊的中间,使其响应

android - 如何在配置前获得 MediaCodec 的最大分辨率

Android Lollipop 问题 - 无法将图像从相机加载到 ImageView

objective-c - 如何显示相机但不让用户拍照?

android - 图片来自相机或画廊?

android - OpenGL-ES:如何在触摸坐标处设置对象?