Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Camera working without camera permission?

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

like image 603
Harald Wilhelm Avatar asked Sep 25 '11 16:09

Harald Wilhelm


2 Answers

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.

like image 188
P.T. Avatar answered Oct 10 '22 14:10

P.T.


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.

like image 1
Philippe Dupuis Avatar answered Oct 10 '22 12:10

Philippe Dupuis