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.my.seams_carv.StartActivity.java

private void dispatchTakePhotoIntent() {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    if (intent.resolveActivity(getPackageManager()) != null) {
        File file = null;//from   w  w w. j  a  v  a  2s  . c o m
        try {
            file = createImageFile();
        } catch (IOException ex) {
            // DO NOTHING.
            Log.d("xyz", ex.getMessage());
        }

        // Continue only if the File was successfully created.
        if (file != null) {
            // Save the path.
            mPhotoPath = Uri.fromFile(file);

            Log.d("xyz", String.format("Saved file=%s", file.getAbsolutePath()));

            // Specify the authorities under which this content provider can
            // be found. Multiple authorities may be supplied by separating
            // them with a semicolon. Authority names should use a Java-style
            // naming convention (such as com.google.provider.MyProvider) in
            // order to avoid conflicts. Typically this name is the same as
            // the class implementation describing the provider's data
            // structure.
            final String authority = getResources().getString(R.string.file_provider_authority);
            final Uri uri = FileProvider.getUriForFile(this, authority, file);
            Log.d("xyz", String.format("Generated uri=%s", uri));

            intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);

            startActivityForResult(intent, REQ_TAKE_PHOTO);
        }
    }
}

From source file:com.luke.lukef.lukeapp.fragments.NewSubmissionFragment.java

/**
 * Activates camera intent//  w w  w  .ja v  a2s . c  o  m
 */
private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getMainActivity().getPackageManager()) != null) {
        // Create the File where the photo should go
        if (photoFile != null) {
            this.photoPath = photoFile.getAbsolutePath();
            // Continue only if the File was successfully created
            Uri photoURI = FileProvider.getUriForFile(getMainActivity(), "com.luke.lukef.lukeapp", photoFile);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
            startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
        } else {
            createImageFile();
            dispatchTakePictureIntent();
        }
    }
}

From source file:io.realm.scanner.MainActivity.java

private void dispatchTakePicture() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        File photoFile = null;//from  ww  w .j a  v  a2 s  .c  o  m
        try {
            photoFile = createImageFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (photoFile != null) {
            currentPhotoPath = photoFile.getAbsolutePath();
            Uri photoURI = FileProvider.getUriForFile(this, "io.realm.scanner.fileprovider", photoFile);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
            startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
        }
    }
}

From source file:nl.basvanmarwijk.mylocations.viewcontroller.LocationItemDetailFragment.java

private void launchCamera() {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    try {/*from w  w w.j a  v  a  2 s  . co  m*/
        pictureUri = ExternalStorageHelper.createUriForNewMediaFile();
        intent.putExtra(MediaStore.EXTRA_OUTPUT, pictureUri);

        startActivityForResult(intent, CAMERA_INTENT_REQUEST_CODE);
    } catch (IOException e) {
        Toast.makeText(getActivity(), R.string.toast_could_not_store_picture, Toast.LENGTH_LONG).show();
    }
}

From source file:com.MustacheMonitor.MustacheMonitor.StacheCam.java

/**
 * Take a picture with the camera.//ww  w.j  av  a2 s  . co  m
 * 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;
 *
 * @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 returnType, int encodingType) {
    // Save the number of images currently on disk for later
    this.numPics = queryImgDB(whichContentStore()).getCount();

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

    // Specify file so that large image is captured and returned
    File photo = createCaptureFile(encodingType);
    intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
    this.imageUri = Uri.fromFile(photo);

    if (this.cordova != null) {
        this.cordova.startActivityForResult((Plugin) this, intent, (CAMERA + 1) * 16 + returnType + 1);
    }
    //        else
    //            LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity");
}

From source file:com.microsoft.assetmanagement.DisplayCarActivity.java

/**
 * Dispatch take picture intent./*from ww w.  ja va 2s.  co m*/
 */
private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException ex) {
            Log.e("Asset", ex.getMessage());
        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
            startActivityForResult(takePictureIntent, CAMARA_REQUEST_CODE);
        }
    }
}

From source file:com.harmazing.aixiumama.activity.ActivityGallery.java

/**
 * ??/*from   ww  w  .j a  v  a2  s  .  c  om*/
 */
private void takePhoto() {
    //??SD??
    String SDState = Environment.getExternalStorageState();
    if (SDState.equals(Environment.MEDIA_MOUNTED)) {
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//"android.media.action.IMAGE_CAPTURE"
        ContentValues values = new ContentValues();
        photoUri = this.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
        CuteApplication.tempUri = photoUri;
        startActivityForResult(intent, SELECT_PIC_BY_TACK_PHOTO);
    } else {
        Toast.makeText(this, "??", Toast.LENGTH_LONG).show();
    }
}

From source file:com.mobicage.rogerthat.GroupDetailActivity.java

private void getNewAvatar(boolean checkPermission) {
    T.UI();/*from w w w  . j ava2s. co m*/
    if (checkPermission) {
        final SafeRunnable continueRunnable = new SafeRunnable() {
            @Override
            protected void safeRun() throws Exception {
                getNewAvatar(false);
            }
        };

        final SafeRunnable runnableCheckStorage = new SafeRunnable() {
            @Override
            protected void safeRun() throws Exception {
                if (askPermissionIfNeeded(Manifest.permission.WRITE_EXTERNAL_STORAGE, PERMISSION_REQUEST_CAMERA,
                        continueRunnable, null))
                    return;
                continueRunnable.run();
            }
        };
        if (askPermissionIfNeeded(Manifest.permission.CAMERA, PERMISSION_REQUEST_CAMERA, runnableCheckStorage,
                null))
            return;
        runnableCheckStorage.run();
        return;
    }
    File image;
    try {
        image = getTmpUploadPhotoLocation();
    } catch (IOException e) {
        L.d(e.getMessage());
        UIUtils.showLongToast(getApplicationContext(), e.getMessage());
        return;
    }
    image.delete();
    mUriSavedImage = Uri.fromFile(image);
    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mUriSavedImage);
    cameraIntent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString());

    Intent galleryIntent = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    galleryIntent.putExtra(MediaStore.EXTRA_OUTPUT, mUriSavedImage);
    galleryIntent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString());
    galleryIntent.setType("image/*");

    PackageManager pm = getPackageManager();
    final Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.select_source));
    if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { cameraIntent });
    }

    startActivityForResult(chooserIntent, PICK_IMAGE);

}

From source file:es.uja.photofirma.android.CameraActivity.java

/**
 * Se ejecuta al pulsar sobre el boton para abrir la captura de fotos, inicia la captura y almacena la fotografa realizada
 *//*ww  w.  jav a  2  s. com*/
public void onTakeAPhoto(View view) {
    logger.appendLog(300, "el usuario abre la aplicacion de fotos");

    //Se crea nueva instancia de la clase PhotoMaker() para automatizar el proceso de trabajo con fotografas
    PhotoCapture = new PhotoMaker();
    File imagen = PhotoCapture.savePhoto();
    photoLocation = imagen.getAbsolutePath();

    //Se redirige al usuario a la app de captura de fotografas
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    takePictureIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(imagen));
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        //         Toast.makeText(getApplicationContext(), getString(R.string.privacy_alert), Toast.LENGTH_LONG).show();
        startActivityForResult(takePictureIntent, CameraActivity.REQUEST_IMAGE_CAPTURE);
    }
}

From source file:com.getchute.android.photopickerplus.ui.activity.ServicesActivity.java

@Override
public void recordVideo() {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    mediaPath = AppUtil.getOutputMediaFileUri(MediaType.VIDEO);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, mediaPath);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
    startTheCamera(intent, Constants.CAMERA_VIDEO_REQUEST);

}