How to capture and save an image using custom camera in Android?

please see below answer. Custom_CameraActivity.java public class Custom_CameraActivity extends Activity { private Camera mCamera; private CameraPreview mCameraPreview; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mCamera = getCameraInstance(); mCameraPreview = new CameraPreview(this, mCamera); FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview); preview.addView(mCameraPreview); Button captureButton = (Button) findViewById(R.id.button_capture); captureButton.setOnClickListener(new View.OnClickListener() … Read more

EXIF orientation tag value always 0 for image taken with portrait camera app android

I also faced same issue in Samsung devices, later I implemented ExifInterface and solved successfully. In any mode images will be shot it will always store in portrait mode only, and while fetching too returning in portrait mode. below of code I used to achieve my goal, I implemented within back camera, not sure about … Read more

Enable rear camera with HTML5

Check out https://simpl.info/getusermedia/sources/ that shows how you can select sources using MediaStreamTrack.getSources(gotSources); You can then select the source and pass it in as optional into getUserMedia var constraints = { audio: { optional: [{sourceId: audioSource}] }, video: { optional: [{sourceId: videoSource}] } }; navigator.getUserMedia(constraints, successCallback, errorCallback); It is now fully available in Stable Chrome and … Read more

Android camera android.hardware.Camera deprecated

API Documentation According to the Android developers guide for android.hardware.Camera, they state: We recommend using the new android.hardware.camera2 API for new applications. On the information page about android.hardware.camera2, (linked above), it is stated: The android.hardware.camera2 package provides an interface to individual camera devices connected to an Android device. It replaces the deprecated Camera class. The … Read more

Intent does not set the camera parameters

Unfortunately, when using the camera with Intent, the only extra parameter you can set is MediaStore.EXTRA_OUTPUT Eg fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name Which allows you to map where the Camera application will store the image. Camera Facing intent extra can sometimes … Read more

How to make video captured by front camera not being inverse Android?

So, if the system camera app produces video similar to your app, you didn’t do something wrong. Now it’s time to understand what happens to front-facing camera video recording. The front facing camera is not different from the rear facing camera in the way it captures still pictures or video. There is a difference how … Read more

How to ask runtime permissions for Camera in Android , Runtime storage permissions

Below I have written a code for granting a runtime permissions for Camera, There is an Array of String in which you can give multiple requests granting as which is needed at runtime. public class MainActivity extends AppCompatActivity { private static final int PERMISSION_REQUEST_CODE = 200; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); if … Read more