未经相机许可相机可以工作吗?
在我们的一个应用程序中,我们使用相机意图来拍照。这适用于真实设备 - 无需相机许可。
这是正确的还是我应该将其添加到此应用程序清单中?
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.Images.Media.DESCRIPTION, "Image capture");
contentValues.put(MediaStore.Images.Media.TITLE, "new image");
Uri uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, 1);
TIA
In one of our applications we use the camera intent to take pictures. This works on real devices - without the camera permission.
Is this correct or should I add it to this apps Manifest?
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.Images.Media.DESCRIPTION, "Image capture");
contentValues.put(MediaStore.Images.Media.TITLE, "new image");
Uri uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(intent, 1);
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看这个:
http://mobile.tutsplus.com/ Tutorials/android/android-sdk-quick-tip-launching-the-camera/
那里注意到了两件事。第一的:
关于权限的说明:
尽管您的应用程序正在利用相机,但它不需要具有 android.permission.CAMERA 权限,因为它不直接访问相机。相反,它只是通过 Intent 启动相机应用程序。
不过,我在developer.android.com上没有看到这一点得到澄清,所以这可能是错误的,并且正在发生其他事情。
看来您只需要直接访问相机原语的权限,而不是通过意图。
请注意,上面的同一 URL 还指出您应该声明该功能,以防止没有摄像头的用户在市场上看到您的应用程序。
See this:
http://mobile.tutsplus.com/tutorials/android/android-sdk-quick-tip-launching-the-camera/
There are two things noted there. First:
A Note on Permissions:
Although your application is leveraging the Camera, it is not required to have the android.permission.CAMERA permission since it is not directly accessing the camera. Instead, it’s just launching the Camera application via Intent.
I don't see this clarified anywhere at developer.android.com, though, so this could be wrong and something else is happening.
It seems you only need the permission to access the camera primitives directly, and not via the Intent.
Note, that the same URL above also points out that you should declare the feature to prevent users without cameras from seeing your app in the market.
为了补充上面的答案,这里有两种访问相机的方法:
在第一种情况下,您使用相机 api 并直接在应用程序中使用相机。因此,您需要请求相机权限(android.permission.CAMERA)。
在第二种情况下,您打开操作系统的相机活动。在这种情况下,Android不需要请求权限。
To add up to the answer above, here are the 2 ways to access the camera :
In the first case, you use the camera api and use the camera directly in you app. Thus, you need to request the camera permission (android.permission.CAMERA).
In the second case, you open the camera activity of the OS. In this case, Android does not require to request the permission.