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:com.dwdesign.tweetings.fragment.UserProfileFragment.java

private void takeBannerPhoto() {
    final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
        final File cache_dir = Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO
                ? GetExternalCacheDirAccessor.getExternalCacheDir(getActivity())
                : new File(getExternalStorageDirectory().getPath() + "/Android/data/"
                        + getActivity().getPackageName() + "/cache/");
        final File file = new File(cache_dir, "tmp_photo_" + System.currentTimeMillis() + ".jpg");
        mImageUri = Uri.fromFile(file);/*from  ww w . j  a  va2 s. c o  m*/
        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageUri);
        startActivityForResult(intent, REQUEST_BANNER_TAKE_PHOTO);
    }
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static Intent createTakePhotoIntent(final Uri uri) {
    final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    return intent;
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static Intent createTakePhotoIntent(final Uri uri, final Integer outputX, final Integer outputY,
        final Integer aspectX, final Integer aspectY, final boolean scaleUpIfNeeded) {
    final Intent intent = new Intent(CameraCropActivity.INTENT_ACTION);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    if (outputX != null && outputY != null) {
        intent.putExtra(CameraCropActivity.EXTRA_OUTPUT_X, outputX);
        intent.putExtra(CameraCropActivity.EXTRA_OUTPUT_Y, outputY);
    }// w w  w  . jav a 2 s .  co  m
    if (aspectX != null && aspectY != null) {
        intent.putExtra(CameraCropActivity.EXTRA_ASPECT_X, aspectX);
        intent.putExtra(CameraCropActivity.EXTRA_ASPECT_Y, aspectY);
    }
    intent.putExtra(CameraCropActivity.EXTRA_SCALE_UP_IF_NEEDED, scaleUpIfNeeded);
    return intent;
}

From source file:com.fvd.nimbus.PaintActivity.java

public void getPhoto() {
    try {//  w  w  w .  j a  va  2 s  .c  o m
        showProgress(true);
        photoFileName = String.valueOf(System.currentTimeMillis()) + "-tmp.jpg";
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        File file = new File(appSettings.getInstance().SavingPath, photoFileName);
        outputFileUri = Uri.fromFile(file);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
        startActivityForResult(intent, TAKE_PHOTO);
        //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
        overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
    } catch (Exception e) {
        appSettings.appendLog("main:getPhoto  " + e.getMessage());
        showProgress(false);
    }
}

From source file:it.feio.android.omninotes.DetailFragment.java

private void takePhoto() {
    // Checks for camera app available
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (!IntentChecker.isAvailable(mainActivity, intent, new String[] { PackageManager.FEATURE_CAMERA })) {
        mainActivity.showMessage(R.string.feature_not_available_on_this_device, ONStyle.ALERT);

        return;//from   w w w .ja  v a 2 s.com
    }
    // Checks for created file validity
    File f = StorageHelper.createNewAttachmentFile(mainActivity, Constants.MIME_TYPE_IMAGE_EXT);
    if (f == null) {
        mainActivity.showMessage(R.string.error, ONStyle.ALERT);
        return;
    }
    // Launches intent
    attachmentUri = Uri.fromFile(f);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, attachmentUri);
    startActivityForResult(intent, TAKE_PHOTO);
}

From source file:it.feio.android.omninotes.DetailFragment.java

private void takeVideo() {
    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if (!IntentChecker.isAvailable(mainActivity, takeVideoIntent,
            new String[] { PackageManager.FEATURE_CAMERA })) {
        mainActivity.showMessage(R.string.feature_not_available_on_this_device, ONStyle.ALERT);

        return;/*from  www.  jav  a  2 s. c  om*/
    }
    // File is stored in custom ON folder to speedup the attachment
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        File f = StorageHelper.createNewAttachmentFile(mainActivity, Constants.MIME_TYPE_VIDEO_EXT);
        if (f == null) {
            mainActivity.showMessage(R.string.error, ONStyle.ALERT);

            return;
        }
        attachmentUri = Uri.fromFile(f);
        takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, attachmentUri);
    }
    String maxVideoSizeStr = "".equals(prefs.getString("settings_max_video_size", "")) ? "0"
            : prefs.getString("settings_max_video_size", "");
    int maxVideoSize = Integer.parseInt(maxVideoSizeStr);
    takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, Long.valueOf(maxVideoSize * 1024 * 1024));
    startActivityForResult(takeVideoIntent, TAKE_VIDEO);
}

From source file:it.feio.android.omninotes.DetailFragment.java

private void takeSketch(Attachment attachment) {

    File f = StorageHelper.createNewAttachmentFile(mainActivity, Constants.MIME_TYPE_SKETCH_EXT);
    if (f == null) {
        mainActivity.showMessage(R.string.error, ONStyle.ALERT);
        return;/*  ww  w .  j  a  v a2  s.c  o m*/
    }
    attachmentUri = Uri.fromFile(f);

    // Forces portrait orientation to this fragment only
    mainActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    // Fragments replacing
    FragmentTransaction transaction = mainActivity.getSupportFragmentManager().beginTransaction();
    mainActivity.animateTransition(transaction, mainActivity.TRANSITION_HORIZONTAL);
    SketchFragment mSketchFragment = new SketchFragment();
    Bundle b = new Bundle();
    b.putParcelable(MediaStore.EXTRA_OUTPUT, attachmentUri);
    if (attachment != null) {
        b.putParcelable("base", attachment.getUri());
    }
    mSketchFragment.setArguments(b);
    transaction.replace(R.id.fragment_container, mSketchFragment, mainActivity.FRAGMENT_SKETCH_TAG)
            .addToBackStack(mainActivity.FRAGMENT_DETAIL_TAG).commit();
}

From source file:com.dycody.android.idealnote.DetailFragment.java

private void takePhoto() {
    // Checks for camera app available
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (!IntentChecker.isAvailable(mainActivity, intent, new String[] { PackageManager.FEATURE_CAMERA })) {
        //mainActivity.showMessage(R.string.feature_not_available_on_this_device, ONStyle.ALERT);
        Toast.makeText(getActivity(), R.string.feature_not_available_on_this_device, Toast.LENGTH_SHORT).show();

        return;//  w  w  w.j a  va  2 s  . co m
    }
    // Checks for created file validity
    File f = StorageHelper.createNewAttachmentFile(mainActivity, Constants.MIME_TYPE_IMAGE_EXT);
    if (f == null) {
        Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show();
        //mainActivity.showMessage(R.string.error, ONStyle.ALERT);
        return;
    }
    // Launches intent
    attachmentUri = Uri.fromFile(f);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, attachmentUri);
    startActivityForResult(intent, TAKE_PHOTO);
}

From source file:com.dycody.android.idealnote.DetailFragment.java

private void takeVideo() {
    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if (!IntentChecker.isAvailable(mainActivity, takeVideoIntent,
            new String[] { PackageManager.FEATURE_CAMERA })) {
        //mainActivity.showMessage(R.string.feature_not_available_on_this_device, ONStyle.ALERT);
        Toast.makeText(getActivity(), R.string.feature_not_available_on_this_device, Toast.LENGTH_SHORT).show();

        return;/*  w w  w  .  jav a 2s.c o m*/
    }
    // File is stored in custom ON folder to speedup the attachment
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        File f = StorageHelper.createNewAttachmentFile(mainActivity, Constants.MIME_TYPE_VIDEO_EXT);
        if (f == null) {
            //mainActivity.showMessage(R.string.error, ONStyle.ALERT);
            Toast.makeText(getActivity(), R.string.error, Toast.LENGTH_SHORT).show();

            return;
        }
        attachmentUri = Uri.fromFile(f);
        takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, attachmentUri);
    }
    String maxVideoSizeStr = "".equals(prefs.getString("settings_max_video_size", "")) ? "0"
            : prefs.getString("settings_max_video_size", "");
    int maxVideoSize = parseInt(maxVideoSizeStr);
    takeVideoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, Long.valueOf(maxVideoSize * 1024 * 1024));
    startActivityForResult(takeVideoIntent, TAKE_VIDEO);
}

From source file:dong.lan.tuyi.activity.MainActivity.java

private void startImageAction(Uri uri, int outputX, int outputY, int requestCode, boolean isCrop) {
    Intent intent = null;/* www . j  a va2  s  .c  o m*/
    if (isCrop) {
        intent = new Intent("com.android.camera.action.CROP");
    } else {
        intent = new Intent(Intent.ACTION_GET_CONTENT, null);
    }
    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", true);
    intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
    intent.putExtra("noFaceDetection", true); // no face detection
    startActivityForResult(intent, requestCode);
}