Example usage for android.provider MediaStore EXTRA_OUTPUT

List of usage examples for android.provider MediaStore EXTRA_OUTPUT

Introduction

In this page you can find the example usage for android.provider MediaStore EXTRA_OUTPUT.

Prototype

String EXTRA_OUTPUT

To view the source code for android.provider MediaStore EXTRA_OUTPUT.

Click Source Link

Document

The name of the Intent-extra used to indicate a content resolver Uri to be used to store the requested image or video.

Usage

From source file:Main.java

public static void getPhotoFromCamera(Activity context, int requestCode, Uri imageUri) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); // set the image file name
    context.startActivityForResult(intent, requestCode);
}

From source file:Main.java

/***
 * Constructs an intent for capturing a photo and storing it in a temporary
 * file./*from  ww w  .  j  a va 2  s. com*/
 */
public static Intent getTakePickIntent(File f) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE, null);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
    return intent;
}

From source file:Main.java

public static void takePicture(Activity mActivity, String imagePath) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (null != imagePath && !imagePath.isEmpty()) {
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(imagePath)));
    }/*  w ww .  j  a  v a 2 s  .c o m*/
    mActivity.startActivityForResult(intent, BBS_REQUEST_CAMERA);
}

From source file:Main.java

public static void openCamera(Context context, int code) {
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
                context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                        new ContentValues()));
        // intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Environment.getExternalStorageDirectory() + imagePath)));
        ((Activity) context).startActivityForResult(intent, code);

    } else//from  w  w  w .j  a va  2  s . co m
        Toast.makeText(context, "no sdcard!", Toast.LENGTH_SHORT).show();
}

From source file:Main.java

public static Intent buildVideoIntent(Context context, Uri uri) {

    String title = "Choose photo";

    //Build galleryIntent
    Intent galleryIntent = new Intent(Intent.ACTION_PICK);

    galleryIntent.setType("video/*");
    //Create chooser
    Intent chooser = Intent.createChooser(galleryIntent, title);

    Intent cameraIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    Intent[] extraIntents = { cameraIntent };
    chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, extraIntents);
    return chooser;

}

From source file:Main.java

private static void cropImageUri(Uri uri, int outputX, int outputY, int requestCode, Activity activity) {
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setDataAndType(uri, "image/*");
    intent.putExtra("crop", "true");
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    intent.putExtra("outputX", outputX);
    intent.putExtra("outputY", outputY);
    intent.putExtra("scale", true);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    intent.putExtra("return-data", false);
    intent.putExtra("scaleUpIfNeeded", true);
    intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
    intent.putExtra("noFaceDetection", true); // no face detection
    activity.startActivityForResult(intent, requestCode);
}

From source file:Main.java

public static Intent capturePhoto(Uri output) {
    final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (output != null) {
        intent.putExtra(MediaStore.EXTRA_OUTPUT, output);
    }/*  w  ww. j a va 2 s . co m*/
    return intent;
}

From source file:Main.java

public static Intent captureVideo(Uri output) {
    final Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if (output != null) {
        intent.putExtra(MediaStore.EXTRA_OUTPUT, output);
    }//w  w w.  j a va 2 s  .com
    return intent;
}

From source file:Main.java

public static Intent getCameraIntent(String outputFile) {
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(outputFile)));
    return intent;
}

From source file:Main.java

public static void startCamera(Activity activity, int requestCode, File outPath) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    Uri uri = Uri.fromFile(outPath);//from  w  ww .  j a  v a 2s . c  o  m
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    activity.startActivityForResult(intent, requestCode);
}