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:cn.ucai.foraging.activity.ChatActivity.java

/**
 * ?/*from w w w.  j a v  a  2  s. co  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(),
            ForagingApplication.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.aibasis.parent.ui.chat.ChatActivity.java

/**
 * ?//from  w w w .  j av  a2 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(),
            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.easemob.chatui.activity.ChatActivity.java

/**
 * ?/* w  w  w .  j a  v  a2 s .  c o  m*/
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        String st = getResources().getString(R.string.sd_card_does_not_exist);
        Toast.makeText(getApplicationContext(), st, Toast.LENGTH_SHORT).show();
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            BeewayApplication.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:org.planetmono.dcuploader.ActivityUploader.java

private void initViews() {
    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    if (wm.getDefaultDisplay().getOrientation() == 0)
        setContentView(R.layout.upload_portrait);
    else// w  w  w.j av a  2s.c  om
        setContentView(R.layout.upload_landscape);

    EditText uploadTarget = (EditText) findViewById(R.id.upload_target);
    EditText uploadTitle = (EditText) findViewById(R.id.upload_title);
    EditText uploadText = (EditText) findViewById(R.id.upload_text);
    Button uploadVisit = (Button) findViewById(R.id.upload_visit);
    Button uploadPhotoTake = (Button) findViewById(R.id.upload_photo_take);
    Button uploadPhotoAdd = (Button) findViewById(R.id.upload_photo_add);
    Button uploadPhotoDelete = (Button) findViewById(R.id.upload_photo_delete);
    CheckBox uploadEnclosePosition = (CheckBox) findViewById(R.id.upload_enclose_position);
    Button uploadOk = (Button) findViewById(R.id.upload_ok);
    Button uploadCancel = (Button) findViewById(R.id.upload_cancel);

    /* set button behavior */

    if (passThrough)
        uploadTarget.setClickable(false);
    else {
        uploadTarget.setClickable(true);
        registerForContextMenu(uploadTarget);
    }

    uploadTarget.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (!passThrough)
                openContextMenu(v);
        }
    });

    registerForContextMenu(uploadVisit);
    uploadVisit.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            openContextMenu(v);
        }
    });

    uploadPhotoTake.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            try {
                tempFile = File.createTempFile("dcuploader_photo_", ".jpg");
            } catch (IOException e) {
                Toast.makeText(ActivityUploader.this, " ??   .",
                        Toast.LENGTH_SHORT).show();

                tempFile = null;

                return;
            }

            Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            if (tempFile != null)
                i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));

            startActivityForResult(i, Application.ACTION_TAKE_PHOTO);
        }
    });

    uploadPhotoAdd.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.setType("image/*");
            i.addCategory(Intent.CATEGORY_DEFAULT);

            startActivityForResult(i, Application.ACTION_ADD_PHOTO);
        }
    });

    uploadPhotoDelete.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Gallery g = (Gallery) findViewById(R.id.upload_images);

            int pos = g.getSelectedItemPosition();
            if (pos == -1)
                return;

            contents.remove(pos);
            bitmaps.remove(pos);

            updateGallery();
            updateImageButtons();

            if (contents.size() == 0)
                pos = -1;
            else if (pos >= contents.size())
                --pos;

            g.setSelection(pos);
        }
    });

    uploadOk.setOnClickListener(proceedHandler);

    uploadCancel.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            finish();
        }
    });

    uploadEnclosePosition.setChecked(formLocation);

    uploadEnclosePosition.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            locationEnabled = isChecked;

            queryLocation(isChecked);
        }
    });

    /* restore data when orientation changes */
    if (formGallery != null) {
        if (target != null) {
            uploadTarget.setText(formGallery);
            formGallery = null;
        }
    }

    if (formTitle != null) {
        uploadTitle.setText(formTitle);
        formTitle = null;
    }

    if (formBody != null) {
        uploadText.setText(formBody);
        formBody = null;
    }

    updateImageButtons();
    updateGallery();
}

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

/**
 * ?/*from  w  w w  .  j  a  v  a2 s . 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(),
            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.app.jiaxiaotong.activity.ChatActivity.java

/**
 * ?/*from   w  ww. j  ava  2  s . 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(),
            AppContext.getAppContext().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.movie.ui.message.ChatActivity.java

/**
 * ?/*from w w  w .jav  a  2s  . 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(),
            NarutoApplication.getApp().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.appstoremedical.activity.ChatActivity.java

/**
 * ?/*from ww  w . j ava2  s  .co 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(),
            AppMedicalApplication.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:cmu.cconfs.instantMessage.activities.ChatActivity.java

/**
 * ?/* w  ww .  j  a v  a2s  .com*/
 */
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(),
            CConfsApplication.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.techscl.ichat.activity.ChatActivity.java

/**
 * ?/*  w ww  .j  a  v a2  s  .c o m*/
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        String st = getResources().getString(R.string.sd_card_does_not_exist);
        To.show(st);
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            LoveChatApp.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);
}