无需使用Android 6.0即可捕获图像

我需要让用户使用 Android 6.0拍摄照片(从画廊或相机应用程序).

因为我不需要控制相机,所以我想用这个描述的意图:

However,if you don’t need such control,you can just use an ACTION_IMAGE_CAPTURE intent to request an image. When you start the intent,the user is prompted to choose a camera app (if there isn’t already a default camera app),and that app takes the picture. The camera app returns the picture to your app’s onActivityResult() method.

https://developer.android.com/preview/features/runtime-permissions.html

但是对于这个ACTION_IMAGE_CAPTURE,您需要将一个Uri的额外的“MediaStore.EXTRA_OUTPUT”填入一个临时文件(没有这个参数,我将只有一个缩略图).此临时文件必须进入外部存储(可由相机应用程序访问).您需要获得WRITE_EXTERNAL_STORAGE权限才能在外部存储上创建一个文件.

所以没有权限的android.permission.CAMERA或android.permission.WRITE_EXTERNAL_STORAGE无法通过本机对话框/应用程序捕获图像.那是对的吗?

谢谢

解决方法

这是可能的,如果你在android 4.4,你可以指定MediaStore.EXTRA_OUTPUT,成为你的包特定的文件
目录

Starting in Android 4.4,the owner,group and modes of files on
external storage devices are Now synthesized based on directory
structure. This enables apps to manage their package-specific
directories
on external storage without requiring they hold the broad
WRITE_EXTERNAL_STORAGE permission. For example,the app with package
name com.example.foo can Now freely access
Android/data/com.example.foo/ on external storage devices with no
permissions.
These synthesized permissions are accomplished by
wrapping raw storage devices in a FUSE daemon.

https://source.android.com/devices/storage/

相关文章

这篇“android轻量级无侵入式管理数据库自动升级组件怎么实现...
今天小编给大家分享一下Android实现自定义圆形进度条的常用方...
这篇文章主要讲解了“Android如何解决字符对齐问题”,文中的...
这篇文章主要介绍“Android岛屿数量算法怎么使用”的相关知识...
本篇内容主要讲解“Android如何开发MQTT协议的模型及通信”,...
本文小编为大家详细介绍“Android数据压缩的方法是什么”,内...