Android Camera Get launchCamera(Activity activity)

Here you can find the source of launchCamera(Activity activity)

Description

launch Camera

Declaration

public static void launchCamera(Activity activity) 

Method Source Code

//package com.java2s;
import java.io.File;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.provider.MediaStore;

public class Main {
    public static int CAMERA_RESULT = 200;

    public static void launchCamera(Activity activity) {
        Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        camera.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
                Uri.fromFile(getFileToStoreCameraResult()));
        activity.startActivityForResult(camera, CAMERA_RESULT);
    }//from w  w  w . j a v a  2s .  c o m

    public static File getFileToStoreCameraResult() {
        String directoryPath = Environment.getExternalStorageDirectory()
                + "/data/yourName/tmp/";
        File directory = new File(directoryPath);
        if (!directory.exists())
            directory.mkdirs();
        String filePath = directoryPath + "camera_capture";
        File file = new File(filePath);
        return file;
    }
}

Related

  1. getNumberOfCameras()
  2. getDefaultBackFacingCameraInstance()
  3. getCameraRotation(final Context context)
  4. indexOfClosestZoom(Camera.Parameters parameters, double targetZoomRatio)
  5. getLowestResolution(Camera.Parameters cp)