Example usage for android.provider MediaStore ACTION_IMAGE_CAPTURE

List of usage examples for android.provider MediaStore ACTION_IMAGE_CAPTURE

Introduction

In this page you can find the example usage for android.provider MediaStore ACTION_IMAGE_CAPTURE.

Prototype

String ACTION_IMAGE_CAPTURE

To view the source code for android.provider MediaStore ACTION_IMAGE_CAPTURE.

Click Source Link

Document

Standard Intent action that can be sent to have the camera application capture an image and return it.

Usage

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

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

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            MyApplication.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.liangxun.university.huanxin.chat.activity.ChatOldActivity.java

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

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            getMyApp().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.lnpdit.chatuidemo.activity.ChatActivity.java

/**
 * ?/*from  ww  w  . j  a v a2  s  . c om*/
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), "SD????", 0).show();
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            CydlApplication.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:cn.kangeqiu.kq.activity.ChatOldActivity.java

/**
 * ?/*  w  w w.j a  va2 s.  c om*/
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), "SD????", 0).show();
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            BaseApplication.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.sxt.superqq.activity.ChatOldActivity.java

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

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            SuperQQApplication.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.hx.hxchat.activity.ChatOldActivity.java

/**
 * ?//ww w . j  a  va2s.c o m
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), "SD????", 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.safeness.im.activity.ChatOldActivity.java

/**
 * ?/*from  ww  w .  j a  va  2 s . com*/
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), "SD????", Toast.LENGTH_LONG).show();
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            PatientApplication.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.easemob.chatuidemo.activity.ChatOldActivity.java

/**
 * ?//  ww  w  .  j a 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;/*from  w ww.ja va 2s.com*/

    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.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 a  2s  . c  om*/

            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();
    }
}