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.easemob.chatuidemo.activity.ChatOldActivity.java

/**
 * ?/*w w w  . ja v a 2 s  .c  o m*/
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), "SD????", 0).show();
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            DemoApplication.getInstance().getUserName() + System.currentTimeMillis() + ".jpg");
    cameraFile.getParentFile().mkdirs();
    startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA);
}

From source file:com.imaginamos.taxisya.taxista.activities.RegisterDriverActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.driver_photo:
        Log.v("onClick", "driver_photo");

        String photoName = getString(R.string.register_driver_photo).replace(" ", "_") + "_" + getCurrentDate();
        mPhotoFilePath = new File(photoFilesDirectory.toString(), photoName + ".jpg");
        Intent photoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        photoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mPhotoFilePath));
        startActivityForResult(photoIntent, CAMERA_PHOTO_REQUEST);
        break;/*  w ww.j av a2 s  . c  o  m*/

    case R.id.driver_document:
        Log.v("onClick", "driver_document");

        String documentName = getString(R.string.register_driver_document_photo).replace(" ", "_") + "_"
                + getCurrentDate();
        mDocumentFilePath = new File(photoFilesDirectory.toString(), documentName + ".jpg");
        Intent documentIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        documentIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mDocumentFilePath));
        startActivityForResult(documentIntent, CAMERA_DOCUMENT_REQUEST);
        break;

    case R.id.driver_document2:
        Log.v("onClick", "driver_document2");

        String document2Name = getString(R.string.register_driver_license_photo).replace(" ", "_") + "_"
                + getCurrentDate();
        mDocument2FilePath = new File(photoFilesDirectory.toString(), document2Name + ".jpg");
        Intent document2Intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        document2Intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mDocument2FilePath));
        startActivityForResult(document2Intent, CAMERA_DOCUMENT2_REQUEST);
        break;

    case R.id.driver_document3:
        Log.v("onClick", "driver_document3");

        String document3Name = getString(R.string.register_driver_card_property).replace(" ", "_") + "_"
                + getCurrentDate();
        mDocument3FilePath = new File(photoFilesDirectory.toString(), document3Name + ".jpg");
        Intent document3Intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        document3Intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mDocument3FilePath));
        startActivityForResult(document3Intent, CAMERA_DOCUMENT3_REQUEST);
        break;

    case R.id.driver_document4:
        Log.v("onClick", "driver_document4");

        String document4Name = getString(R.string.register_driver_card_operation).replace(" ", "_") + "_"
                + getCurrentDate();
        mDocument4FilePath = new File(photoFilesDirectory.toString(), document4Name + ".jpg");
        Intent document4Intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        document4Intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mDocument4FilePath));
        startActivityForResult(document4Intent, CAMERA_DOCUMENT4_REQUEST);
        break;

    /* case R.id.btn_volver:
        finish();
        break;*/

    default:
        break;

    }
}

From source file:com.interestfriend.activity.ChatActivity.java

/**
 * //from  w  w  w .  j a  va 2s. c o  m
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), "SD", 0).show();
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            SharedUtils.getHXId() + System.currentTimeMillis() + ".jpg");
    cameraFile.getParentFile().mkdirs();
    startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA);
}

From source file:com.givon.anhao.activity.ChatActivity.java

/**
 * ?//from   w w w .j av a  2  s .co m
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), "SD????", 0).show();
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            AnhaoApplication.getInstance().getUserName() + System.currentTimeMillis() + ".jpg");
    cameraFile.getParentFile().mkdirs();
    startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA);
}

From source file:com.runye.express.chat.activity.ChatActivity.java

/**
 * ?//from ww w .j a va2s  .co  m
 */
public void selectVideoFromCamera() {
    if (!CommonUtil.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), "SD????", 0).show();
        return;
    }

    videoFile = new File(PathUtil.getInstance().getVideoPath(),
            MyApplication.getInstance().getUserName() + System.currentTimeMillis() + ".mp4");
    videoFile.getParentFile().mkdirs();
    startActivityForResult(new Intent(MediaStore.ACTION_VIDEO_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(videoFile)), REQUEST_CODE_CAMERA_VIDEO);

}

From source file:com.hx.hxchat.activity.ChatActivity.java

/**
 * ?// www.j  ava2s . c o m
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        String st = getResources().getString(R.string.sd_card_does_not_exist);
        Toast.makeText(getApplicationContext(), st, 0).show();
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            BaseApplication.getApplication().getUserName() + System.currentTimeMillis() + ".jpg");
    cameraFile.getParentFile().mkdirs();
    startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA);
}

From source file:com.qiscus.sdk.ui.fragment.QiscusBaseChatFragment.java

protected void takeImage() {
    if (QiscusPermissionsUtil.hasPermissions(getActivity(), FILE_PERMISSION)) {
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
            File photoFile = null;
            try {
                photoFile = QiscusImageUtil.createImageFile();
            } catch (IOException ex) {
                showError(getString(R.string.chat_error_failed_write));
            }//from  w w  w  .  ja  v a2 s  . co  m

            if (photoFile != null) {
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
                    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
                } else {
                    intent.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile(getActivity(),
                            Qiscus.getProviderAuthorities(), photoFile));
                }
                startActivityForResult(intent, TAKE_PICTURE_REQUEST);
            }
            hideAttachmentPanel();
        }
    } else {
        requestPermissions();
    }
}

From source file:com.nanostuffs.yurdriver.fragment.RegisterFragment.java

private void takePhotoFromCamera() {
    Calendar cal = Calendar.getInstance();
    File file = new File(Environment.getExternalStorageDirectory(), (cal.getTimeInMillis() + ".jpg"));

    if (!file.exists()) {
        try {/*www . j a va  2s  .  c om*/
            file.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {

        file.delete();
        try {
            file.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    uri = Uri.fromFile(file);
    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    registerActivity.startActivityForResult(cameraIntent, AndyConstants.TAKE_PHOTO,
            AndyConstants.REGISTER_FRAGMENT_TAG);
}

From source file:com.mobicage.rogerthat.util.ui.SendMessageView.java

private void getNewVideo(boolean checkPermission) {
    if (checkPermission) {
        askCameraPermission(true, new SafeRunnable() {
            @Override/*from w  w  w.  j  a v a 2s  .  co m*/
            protected void safeRun() throws Exception {
                getNewVideo(false);
            }
        });
        return;
    }

    if (!setupUploadFile("mp4", true)) {
        return;
    }

    Intent galleryIntent = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    galleryIntent.putExtra(MediaStore.EXTRA_OUTPUT, mUriSavedFile);
    galleryIntent.setType(AttachmentViewerActivity.CONTENT_TYPE_VIDEO_MP4);

    final Intent chooserIntent = Intent.createChooser(galleryIntent,
            mActivity.getString(R.string.select_source));
    if (mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)
            && mMainService.isPermitted(Manifest.permission.CAMERA)) {
        Intent cameraIntent = ActivityUtils.buildMakeVideoIntent(mActivity, mUriSavedFile);
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { cameraIntent });
    }

    mActivity.startActivityForResult(chooserIntent, PICK_VIDEO);
}

From source file:com.erhuoapp.erhuo.activity.ChatActivity.java

/**
 * ?/*  w  ww.ja va  2  s . c om*/
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        String st = getResources().getString(R.string.sd_card_does_not_exist);
        Toast.makeText(getApplicationContext(), st, 0).show();
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            ErHuoApplication.getInstance().getUserName() + System.currentTimeMillis() + ".jpg");
    cameraFile.getParentFile().mkdirs();
    startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA);
}