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.zns.comicdroid.activity.Edit.java

@Override
public void onClick(View v) {
    if (v.getId() == R.id.comicEdit_ivImage) {
        if (mComics == null) {
            Toast.makeText(Edit.this, getResources().getString(R.string.edit_needtosave), Toast.LENGTH_LONG)
                    .show();/*from   w  w w. ja  v  a2 s  . c o m*/
            return;
        }
        Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        String fileName = "thumb" + mComics.get(0).hashCode() + ".jpg";
        mNewImage = getImagePath(fileName);
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(mNewImage)));
        startActivityForResult(cameraIntent, CAMERA_REQUEST);
    }
}

From source file:cn.zsmy.akm.doctor.profile.fragment.DoctorLicenseFragment.java

@Override
public void onItemClick(int position) {
    switch (position) {
    case 0://  ww  w.  j av a 2s  .c om
        PHOTO_CREAME = CREAME;
        Intent openCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/"
                + String.valueOf(System.currentTimeMillis()) + ".jpg");
        tempUri = Uri.fromFile(file);
        openCameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, tempUri);
        startActivityForResult(openCameraIntent, PIC);

        break;
    case 1:
        PHOTO_CREAME = PHOTO;
        Intent i = new Intent(Intent.ACTION_PICK,
                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        startActivityForResult(i, PIC);
        break;
    }
    WHETHER_FROM_ACTIVITY_BACK = true;
}

From source file:com.kayzook.bracediary.BaseActivity.java

public void takePhoto(View view) {
    Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    fileUri = Uri.fromFile(getOutputPhotoFile());
    i.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
    startActivityForResult(i, CAPTURE_IMAGE_ACTIVITY_REQ);
}

From source file:net.jongrakko.zipsuri.activity.PostReviseActivity.java

private void takeVideo() {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    takeFile = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
            "Zisuri_tmp_" + System.currentTimeMillis() + ".mp4");
    Uri saveUri = Uri.fromFile(takeFile);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, saveUri); // set the image file name
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set the video image quality to high
    startActivityForResult(intent, TAKE_VIDEO_FOR_AVATAR);
}

From source file:com.paramedic.mobshaman.fragments.AccionesDetalleServicioFragment.java

/**
 * Start the camera by dispatching a camera intent.
 *///from w ww. ja  v a 2  s . c  o  m
protected void dispatchTakePictureIntent(boolean isFinishingService) {

    // Check if there is a camera.
    Context context = getActivity();
    PackageManager packageManager = context.getPackageManager();
    if (packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA) == false) {
        Toast.makeText(getActivity(), "This device does not have a camera.", Toast.LENGTH_SHORT).show();
        return;
    }

    // Camera exists? Then proceed...
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    // Ensure that there's a camera activity to handle the intent
    DetalleServicioActivity activity = (DetalleServicioActivity) getActivity();
    if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) {
        // Create the File where the photo should go.
        // If you don't do this, you may get a crash in some devices.
        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException ex) {
            // Error occurred while creating the File
            Toast toast = Toast.makeText(activity, "There was a problem saving the photo...",
                    Toast.LENGTH_SHORT);
            toast.show();
        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
            Uri fileUri = Uri.fromFile(photoFile);
            activity.setCapturedImageURI(fileUri);
            activity.setCurrentPhotoPath(fileUri.getPath());
            activity.setIsFinishingService(isFinishingService);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, activity.getCapturedImageURI());

            startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
        }
    }
}

From source file:au.org.ala.fielddata.mobile.CollectSurveyData.java

/**
 * Launches the default camera application to take a photo and store the
 * result for the supplied attribute.//ww w  .ja v a  2  s. co  m
 * 
 * @param attribute
 *            the attribute the photo relates to.
 */
public void takePhoto(Attribute attribute) {
    if (StorageManager.canWriteToExternalStorage()) {
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        Uri fileUri = StorageManager.getOutputMediaFileUri(StorageManager.MEDIA_TYPE_IMAGE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
        // Unfortunately, this URI isn't being returned in the
        // result as expected so we have to save it somewhere it can
        // survive an activity restart.
        surveyViewModel.setTempValue(attribute, fileUri.toString());
        startActivityForResult(intent, CollectSurveyData.TAKE_PHOTO_REQUEST);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Cannot take photo")
                .setMessage("Please ensure you have mounted your SD card and it is writable")
                .setPositiveButton("OK", null).show();
    }
}

From source file:com.pizidea.imagepicker.AndroidImagePicker.java

/**
 * take picture/*from w w  w.  j  a  va 2s .  c  o  m*/
 */
public void takePicture(Fragment fragment, int requestCode) throws IOException {

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    //Intent takePictureIntent = new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
    takePictureIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(fragment.getActivity().getPackageManager()) != null) {
        // Create the File where the photo should go
        //File photoFile = createImageFile();
        File photoFile = createImageSaveFile(fragment.getActivity());
        // Continue only if the File was successfully created
        if (photoFile != null) {
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
            Log.i(TAG, "=====file ready to take photo:" + photoFile.getAbsolutePath());
        }
    }
    fragment.startActivityForResult(takePictureIntent, requestCode);

}

From source file:info.papdt.blacklight.ui.statuses.NewPostActivity.java

private void showPicturePicker() {
    new AlertDialog.Builder(this).setItems(getResources().getStringArray(R.array.picture_picker_array),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialogInterface, int id) {
                    switch (id) {
                    case 0:
                        Intent i = new Intent();
                        if (Build.VERSION.SDK_INT >= 19) {
                            i.setAction(Intent.ACTION_OPEN_DOCUMENT);
                            i.addCategory(Intent.CATEGORY_OPENABLE);
                            i.setType("image/*");
                        } else {
                            i.setAction(Intent.ACTION_PICK);
                            i.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                        }/* w ww  . j ava2  s.com*/
                        startActivityForResult(i, REQUEST_PICK_IMG);
                        break;
                    case 1:
                        Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                        Uri uri = Utility.getOutputMediaFileUri();
                        captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
                        startActivityForResult(captureIntent, REQUEST_CAPTURE_PHOTO);
                        break;
                    case 2:
                        Intent multi = new Intent();
                        multi.setAction("us.shandian.blacklight.MULTI_PICK");
                        multi.setClass(NewPostActivity.this, MultiPicturePicker.class);
                        startActivityForResult(multi, 1000);
                        break;
                    }
                }
            }).show();
}

From source file:com.rsmsa.accapp.MainActivity.java

/**
 * Capturing Camera Image will lauch camera app requrest image capture
 *//* ww  w .  j a  v a 2 s. c om*/
private void captureImage() {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

    // start the image capture Intent
    startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
}

From source file:com.dazone.crewchat.libGallery.activity.HomeFragmentActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.cameraImageViewFromMediaChooserHeaderBar:
        if (v.getTag().toString().equals(getResources().getString(R.string.video))) {
            Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
            fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_VIDEO); // create a file to save the image
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name

            // start the image capture Intent
            startActivityForResult(intent, MediaChooserConstants.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);

        } else {//from   w  w w  .ja v  a2  s .c  o m
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_IMAGE); // create a file to save the image
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name

            // start the image capture Intent
            startActivityForResult(intent, MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
        }
        break;
    case R.id.doneTextViewViewFromMediaChooserHeaderView:
        FragmentManager fragmentManager = getSupportFragmentManager();
        ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1");
        VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2");

        if (videoFragment != null || imageFragment != null) {

            if (videoFragment != null) {
                if (videoFragment.getSelectedVideoList() != null
                        && videoFragment.getSelectedVideoList().size() > 0) {
                    Intent videoIntent = new Intent();
                    videoIntent.setAction(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                    videoIntent.putStringArrayListExtra("list", videoFragment.getSelectedVideoList());
                    sendBroadcast(videoIntent);
                } else {
                    Toast.makeText(HomeFragmentActivity.this, getString(R.string.please_select_file),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
            }

            if (imageFragment != null) {
                if (imageFragment.getSelectedImageList() != null
                        && imageFragment.getSelectedImageList().size() > 0) {
                    Intent imageIntent = new Intent();
                    imageIntent.setAction(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                    imageIntent.putStringArrayListExtra("list", imageFragment.getSelectedImageList());
                    sendBroadcast(imageIntent);
                } else {
                    Toast.makeText(HomeFragmentActivity.this, getString(R.string.please_select_file),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
            }
            if (BucketHomeFragmentActivity.Instance != null) {
                BucketHomeFragmentActivity.Instance.finish();
            }
            finish();
        } else {
            Toast.makeText(HomeFragmentActivity.this, getString(R.string.please_select_file),
                    Toast.LENGTH_SHORT).show();
        }
        break;
    case R.id.backArrowImageViewFromMediaChooserHeaderView:
        finish();
        break;
    default:
        break;
    }
}