开发者

Camera working without camera permission?

In one of our applicatio开发者_开发问答ns 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


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.


To add up to the answer above, here are the 2 ways to access the camera :

  • https://developer.android.com/guide/topics/media/camera
  • https://developer.android.com/training/camera/photobasics

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜