因为我不需要控制相机,所以我想用这个描述的意图:
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无法通过本机对话框/应用程序捕获图像.那是对的吗?
谢谢
解决方法
目录
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.