Intent does not set camera parameters

I open the application for the camera as an external intention from my applications. I use the following code to call the camera, and the following are my conditions:

  • He should open the front camera.
  • Highest image quality.
  • Flash indicator must be on.

Below is my code:

Intent action = new Intent("android.media.action.IMAGE_CAPTURE"); action.putExtra("android.intent.extras.CAMERA_FACING", 1); action.putExtra("android.intent.extras.FLASH_MODE_ON", 1); action.putExtra("android.intent.extras.QUALITY_HIGH", 1); 

Now he opens the front camera, but it does not turn on the flash, and it does not set high image quality.

The My Manifest file resolution section is as follows:

 <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.FLASHLIGHT"/> <uses-feature android:name="android.hardware.camera" /> <uses-feature android:name="android.hardware.camera.autofocus" /> <uses-feature android:name="android.hardware.camera.flash" /> 

Is there anything that I am missing?

+3
android android-intent camera android-camera android-intent
source share
2 answers

Unfortunately, when using a camera with Intent, the only additional option you can set is

 MediaStore.EXTRA_OUTPUT 

For example,

 fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name 

Lets you match where the camera application will save the image.

Sometimes it’s possible to work with the Camera Image object:

 action.putExtra("android.intent.extras.CAMERA_FACING", 1); 

There are some β€œtest” methods in the Android source files that are in the Util class file but are not officially documented:

(Util)

 private static final String EXTRAS_CAMERA_FACING = "android.intent.extras.CAMERA_FACING"; // This is for test only. Allow the camera to launch the specific camera. public static int getCameraFacingIntentExtras(Activity currentActivity) { int cameraId = -1; int intentCameraId = currentActivity.getIntent().getIntExtra(Util.EXTRAS_CAMERA_FACING, -1); if (isFrontCameraIntent(intentCameraId)) { // Check if the front camera exist int frontCameraId = CameraHolder.instance().getFrontCameraId(); if (frontCameraId != -1) { cameraId = frontCameraId; } } else if (isBackCameraIntent(intentCameraId)) { // Check if the back camera exist int backCameraId = CameraHolder.instance().getBackCameraId(); if (backCameraId != -1) { cameraId = backCameraId; } } return cameraId; } 

And in the photomodule the following method is used:

(photo module)

 private int getPreferredCameraId(ComboPreferences preferences) { int intentCameraId = Util.getCameraFacingIntentExtras(mActivity); if (intentCameraId != -1) { // Testing purpose. Launch a specific camera through the intent // extras. return intentCameraId; } else { return CameraSettings.readPreferredCameraId(preferences); } } 

And when the camera application initializes the photo mode, it calls this method to check which camera to use:

 mCameraId = getPreferredCameraId(mPreferences); 
+6
source share
 intent.putExtra("android.intent.extras.CAMERA_FACING", android.hardware.Camera.CameraInfo.CAMERA_FACING_FRONT); 

this intention is to start capturing from the front camera instead of the default default camera.

this works the way it is used in this popular cordova plugin in this link on line 145: https://github.com/EddyVerbruggen/VideoCapturePlus-PhoneGap-Plugin/blob/master/src/android/nl/xservices/plugins/videocaptureplus /VideoCapturePlus.java

Hope this helps anyone who is facing the same problem.

Do you also know if you can set the intention to disable the camera controls (filters, switch between cameras ... etc) so that they do not appear?

0
source share

All Articles