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.polyvi.xface.extension.camera.XCameraExt.java

public void takePicture(int mEncodingType) {
    Cursor cursor = queryImgDB();
    if (null != cursor) {
        mNumPics = cursor.getCount();// ??
    } else {/* w ww  .  ja v a  2s.co m*/
        mNumPics = 0;//Cursor
    }

    // ?camera?
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    File photo = createCaptureFile(mEncodingType); // 

    // ?URI???
    intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
    mImageUri = Uri.fromFile(photo);

    // ?Camera??onActivityResult?
    mExtensionContext.getSystemContext().startActivityForResult(this, intent, CAMERA_REQUEST_CODE);
}

From source file:com.sandklef.coachapp.fragments.TrainingPhasesFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo acmi = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    int position = acmi.position;

    String fileName = LocalStorage.getInstance().getNewMediaDir() + "/tp-" + currentTPId
            + JsonSettings.SERVER_VIDEO_SUFFIX;
    Media m = Media.newInstructionVideo(fileName, currentTPId);
    currentTPId = null;/*from w  ww. j  a va 2s . c o m*/
    Uri uri = Uri.fromFile(new File(fileName));

    if (m != null) {
        Log.d(LOG_TAG, "   instruction video item: " + fileName);
        Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

        Log.d(LOG_TAG, "  file: " + fileName + " uri: " + uri);

        intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
        intent.putExtra("android.intent.extra.durationLimit", 5);
        intent.putExtra(MediaStore.EXTRA_FINISH_ON_COMPLETION, true);
        intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 5);
        intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set the video image quality to high
        // start the image capture Intent
        //context.startActivity(intent);
        //            activity.startActivityForResult(intent, com.sandklef.coachapp.fragments.VideoCapture.VIDEO_CAPTURE);
        ((Activity) getContext()).startActivityForResult(intent, VIDEO_CAPTURE);
    }
    Log.d(LOG_TAG, "  new instruction video wanted creation: " + fileName);

    return true;
}

From source file:com.grokkingandroid.sampleapp.samples.data.contentprovider.lentitems.LentItemFormFragment.java

private void addPhoto() {
    // checking for intent availability is ignored here
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    mOldPhotoUri = mPhotoUri;/*w w w  .j  av a 2  s .  c o m*/
    mPhotoUri = createPhotoUri();
    intent.putExtra(MediaStore.EXTRA_OUTPUT, mPhotoUri);
    mWasActivityForResultStarted = true;
    startActivityForResult(intent, RC_PHOTO);
}

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

public void save() {
    Bitmap bitmap = mSketchView.getBitmap();
    if (bitmap != null) {

        try {// w w  w  .  jav  a  2  s  . com
            Uri uri = getArguments().getParcelable(MediaStore.EXTRA_OUTPUT);
            File bitmapFile = new File(uri.getPath());
            FileOutputStream out = new FileOutputStream(bitmapFile);
            bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
            out.close();
            if (bitmapFile.exists()) {
                getMainActivity().sketchUri = uri;
            } else {
                getMainActivity().showMessage(R.string.error, ONStyle.ALERT);
            }

        } catch (Exception e) {
            Log.e(Constants.TAG, "Error writing sketch image data", e);
        }
    }
}

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

@Override
public void takePhoto() {
    if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
        NotificationUtil.makeToast(getApplicationContext(), R.string.toast_feature_camera);
        return;/*from ww  w.  j  a  va 2 s .c om*/
    }
    final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (AppUtil.hasImageCaptureBug() == false) {
        intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(AppUtil.getTempImageFile(ServicesActivity.this)));
    } else {
        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    }
    startActivityForResult(intent, Constants.CAMERA_PIC_REQUEST);
}

From source file:com.mifos.mifosxdroid.online.ClientDetailsFragment.java

public void captureClientImage() {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(capturedClientImageFile));
    startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}

From source file:com.anhubo.anhubo.ui.activity.unitDetial.UploadingActivity1.java

private void takePhoto() {
    //?? ??//from  www . j  a va  2 s . c  o m
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
    Date date = new Date(System.currentTimeMillis());
    String filename = format.format(date);
    File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
    File outputImage = new File(path, filename + ".jpg");
    try {
        if (outputImage.exists()) {
            outputImage.delete();
        }
        outputImage.createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
    }
    //File?Uri??
    if (Build.VERSION.SDK_INT < 24) {

        imageUri = Uri.fromFile(outputImage);
    } else {
        imageUri = FileProvider.getUriForFile(mActivity, "com.luoli.cameraalbumtest.fileprovider", outputImage);
    }
    Intent tTntent = new Intent("android.media.action.IMAGE_CAPTURE"); //
    tTntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); //?
    startActivityForResult(tTntent, CAMERA); //?

}

From source file:com.example.linhdq.test.documents.creation.NewDocumentActivity.java

protected void startCamera() {
    try {/*from   w  w  w. java2  s.  c  o  m*/
        cameraPicUri = null;
        dateCameraIntentStarted = new Date();
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        // Create an image file name
        String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date());
        String imageFileName = "JPEG_" + timeStamp + "_";

        File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
        File image;
        try {
            if (!storageDir.exists()) {
                storageDir.mkdirs();
            }
            image = new File(storageDir, imageFileName + ".jpg");
            if (image.exists()) {
                image.createNewFile();
            }
            cameraPicUri = Uri.fromFile(image);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraPicUri);
            startActivityForResult(intent, REQUEST_CODE_MAKE_PHOTO);
        } catch (IOException e) {
            showFileError(PixLoadStatus.IO_ERROR);
        }

    } catch (ActivityNotFoundException e) {
        showFileError(PixLoadStatus.CAMERA_APP_NOT_FOUND);
    }
}

From source file:net.survivalpad.android.ArticleEditActivity.java

@Override
public void onTakePictureClicked(BaseEditorFragment fragment) {
    mEditorFragment = fragment;//from   w  w w  .j  a  v a2 s.c om

    fileUri = MediaUtils.getOutputMediaFileUri();

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
    }
}

From source file:io.ingame.squarecamera.CameraLauncher.java

private void setOutputUri(Intent intent, Uri uri) {
    intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, uri);

    JSONObject response;//from  w w w.jav  a2 s .c o  m
    try {
        response = new JSONObject();
        response.put("uri", uri.toString());
        response.put("pending", true);
    } catch (JSONException e) {
        Log.e(LOG_TAG, "On pending result creation" + e);
        return;
    }

    PluginResult r = new PluginResult(PluginResult.Status.OK, response);
    r.setKeepCallback(true);
    callbackContext.sendPluginResult(r);
}