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.ez.gallery.PhotoBaseActivity.java

/**
 * ?/*from w  ww  .j a v  a  2 s . c  o  m*/
 */
protected void takePhotoAction() {
    if (!DeviceUtils.existSDCard()) {
        String errormsg = getString(R.string.empty_sdcard);
        toast(errormsg);
        if (mTakePhotoAction) {
            resultFailure(errormsg, true);
        }
        return;
    }

    File takePhotoFolder;
    if (StringUtils.isEmpty(mPhotoTargetFolder)) {
        takePhotoFolder = Picseler.getCoreConfig().getTakePhotoFolder();
    } else {
        takePhotoFolder = new File(mPhotoTargetFolder);
    }
    boolean suc = FileUtils.mkdirs(takePhotoFolder);
    File toFile = new File(takePhotoFolder, "IMG" + DateUtils.format(new Date(), "yyyyMMddHHmmss") + ".jpg");

    if (suc) {
        mTakePhotoUri = Uri.fromFile(toFile);
        Uri uri = FileProvider.getUriForFile(this, Picseler.getCoreConfig().getFileProvider(), toFile);//FileProvidercontentUri
        Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        captureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        startActivityForResult(captureIntent, Picseler.TAKE_REQUEST_CODE);
    } else {
        takePhotoFailure();
    }
}

From source file:ca.cmput301f13t03.adventure_datetime.view.FullScreen_Image.java

private void setUpView() {
    if (_fragment == null)
        return;/*from  ww  w  .ja v  a2 s.c  o  m*/
    if (_pageAdapter == null)
        return;

    Button gallery = (Button) findViewById(R.id.gallery);
    Button camera = (Button) findViewById(R.id.camera);
    Button delete = (Button) findViewById(R.id.action_delete);

    gallery.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(i, GALLERY);
        }

    });
    camera.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            File picDir = new File(
                    Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
                    "adventure.datetime");
            if (!picDir.exists())
                picDir.mkdirs();
            File pic = new File(picDir.getPath(), File.separator + _fragment.getFragmentID().toString() + "-"
                    + _fragment.getStoryMedia().size());
            _newImage = Uri.fromFile(pic);
            Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            i.putExtra(MediaStore.EXTRA_OUTPUT, _newImage);
            startActivityForResult(i, CAMERA);
        }
    });

    _pageAdapter.setIllustrations(_fragment.getStoryMedia(), getIntent().getBooleanExtra(TAG_AUTHOR, false));
    /*  ArrayList<String> list = new ArrayList<String>();
      for (int i=0; i<5; i++) list.add(""+i);
      _pageAdapter.setIllustrations(list, getIntent().
        getBooleanExtra(TAG_AUTHOR, false));*/
}

From source file:com.monmonja.library.social.SocialNetworkDialogFragment.java

/** * Start the camera by dispatching a camera intent. */
protected void dispatchTakePictureIntent() {
    PackageManager packageManager = getActivity().getPackageManager();
    if (!packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
        Toast.makeText(getActivity(), "This device does not have a camera.", Toast.LENGTH_SHORT).show();
        return;/* www .java  2s.c  o m*/
    }

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
        try {
            File tempFile = getTempCaptureImgPath();
            mTempTakePicturePath = tempFile.getAbsolutePath();
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));
            startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
        } catch (IOException ex) {

        }

    }
}

From source file:com.phonegap.customcamera.NativeCameraLauncher.java

public void takePicture() {
    // Save the number of images currently on disk for later
    Intent intent = new Intent(this.cordova.getActivity().getApplicationContext(), CameraActivity.class);
    this.photo = createCaptureFile();
    this.imageUri = Uri.fromFile(photo);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, this.imageUri);
    intent.putExtra(CAPTURE_BUTTON_COLOR_ID, this.captureButtonColor);
    intent.putExtra(CAPTURE_BUTTON_BORDER_COLOR_ID, this.captureButtonBorderColor);
    intent.putExtra(BRIGHTNESS_THRESHOLD_ID, this.brightnessThreshold);
    this.cordova.startActivityForResult((CordovaPlugin) this, intent, 1);
}

From source file:com.albedinsky.android.support.intent.VideoIntent.java

/**
 * Creates a new instance of Intent with {@link MediaStore#ACTION_VIDEO_CAPTURE}
 * that can be used to launch a camera app to capture a single video.
 *
 * @param outputUri If not {@code null}, it will be attached to intent as {@link MediaStore#EXTRA_OUTPUT},
 *                  so when the result is received in for example {@link Activity#onActivityResult(int, int, Intent)},
 *                  the <var>outputUri</var> will address to a file which contains the currently
 *                  captured video./*from  w  w  w. ja v  a 2s.  c  o m*/
 * @return New camera intent instance.
 * @see #createCameraIntent(File)
 */
@NonNull
public static Intent createCameraIntent(@Nullable Uri outputUri) {
    final Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if (outputUri != null) {
        intent.putExtra(MediaStore.EXTRA_OUTPUT, outputUri);
    }
    return intent;
}

From source file:com.happiestminds.template.ui.activity.ItemDetailActivity.java

public void onButtonClick(View v) {
    //Crop.pickImage(this);

    final CharSequence[] items = { ImageCaptureType.CAPTURE_BY_CAMERA.toString(),
            ImageCaptureType.CAPTURE_BY_CAMERA_WITHCROP.toString(),
            ImageCaptureType.CAPTURE_BY_GALLERY.toString(),
            ImageCaptureType.CAPTURE_BY_GALLERY_WITHCROP.toString(), "Download Image",
            ImageCaptureType.CAPTURE_BY_CAMERA_ORIGINAL.toString() };
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Make your selection");
    builder.setItems(items, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {

            switch (item) {
            case 0:
                ImageServices.imageCapture(ItemDetailActivity.this, ImageCaptureType.CAPTURE_BY_CAMERA);
                break;
            case 1:
                ImageServices.imageCapture(ItemDetailActivity.this,
                        ImageCaptureType.CAPTURE_BY_CAMERA_WITHCROP);
                break;
            case 2:
                ImageServices.imageCapture(ItemDetailActivity.this, ImageCaptureType.CAPTURE_BY_GALLERY);
                break;
            case 3:
                ImageServices.imageCapture(ItemDetailActivity.this,
                        ImageCaptureType.CAPTURE_BY_GALLERY_WITHCROP);
                break;
            case 4:
                ImageServices.displayImageFromUrl(
                        "http://farm6.staticflickr.com/5344/9049177018_4621cb63db_s.jpg", imageView);
                break;
            case 5:
                imageUri = ImageServices.getOutputMediaFileUri();
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
                startActivityForResult(intent,
                        ImageCaptureType.CAPTURE_BY_CAMERA_ORIGINAL.getImageCaptureType());
                break;
            }//from   ww w.  j a v a 2s  .c om
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.king.base.util.SystemUtils.java

/**
 * ?/*  w  w w . j  a v  a  2s . c  o  m*/
 *
 * @param fragment
 * @param path
 * @param requestCode
 */
public static void imageCapture(Fragment fragment, String path, int requestCode) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (!TextUtils.isEmpty(path)) {
        Uri uri = null;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            uri = FileProvider.getUriForFile(fragment.getContext(),
                    fragment.getContext().getPackageName() + ".fileProvider", new File(path));
        } else {
            uri = Uri.fromFile(new File(path));
        }
        intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    }
    fragment.startActivityForResult(intent, requestCode);
}

From source file:net.mutina.uclimb.ForegroundCameraLauncher.java

/**
 * Take a picture with the camera.//from   w  w  w  .  j a  va 2  s .  c om
 * When an image is captured or the camera view is cancelled, the result is returned
 * in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult.
 * 
 * The image can either be returned as a base64 string or a URI that points to the file.
 * To display base64 string in an img tag, set the source to:
 *      img.src="data:image/jpeg;base64,"+result;
 * or to display URI in an img tag
 *      img.src=result;
 * 
 */
public void takePicture() {
    // Save the number of images currently on disk for later
    this.numPics = queryImgDB().getCount();

    Intent intent = new Intent(this.ctx.getContext(), CameraActivity.class);
    this.photo = createCaptureFile();
    this.imageUri = Uri.fromFile(photo);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, this.imageUri);

    this.ctx.startActivityForResult((Plugin) this, intent, 1);
}

From source file:com.phonegap.CameraLauncher.java

/**
 * Take a picture with the camera./*from w  ww.  ja va 2  s.c  om*/
 * When an image is captured or the camera view is cancelled, the result is returned
 * in PhonegapActivity.onActivityResult, which forwards the result to this.onActivityResult.
 * 
 * The image can either be returned as a base64 string or a URI that points to the file.
 * To display base64 string in an img tag, set the source to:
 *       img.src="data:image/jpeg;base64,"+result;
 * or to display URI in an img tag
 *       img.src=result;
 * 
 * @param quality         Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
 * @param returnType      Set the type of image to return. 
 */
public void takePicture(int quality, int returnType) {
    this.mQuality = quality;

    // Display camera
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");

    // Specify file so that large image is captured and returned
    // TODO: What if there isn't any external storage?
    File photo = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
    intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
    this.imageUri = Uri.fromFile(photo);

    this.ctx.startActivityForResult((Plugin) this, intent, (CAMERA + 1) * 16 + returnType + 1);
}

From source file:com.photocitygame.android.ImageActivity.java

protected void doCapture() {
    File f = Environment.getExternalStorageDirectory();
    File dir = new File(f, "photocity");
    if (!dir.exists()) {
        dir.mkdir();//from  w  ww.  j  a  v  a  2s. c o  m
    }
    Uri captureUri = Uri.fromFile(new File(dir, "image.jpg"));
    Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    i.putExtra(MediaStore.EXTRA_OUTPUT, captureUri);
    startActivityForResult(i, TAKE_IMAGE);
}