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.dlam.activity.ChatActivity.java

/**
 * ?//  w w  w . j av  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

/**
 * ?/* w w  w  .  j  a  va  2s .  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(),
            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: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/*from ww w.  j  a  v  a  2  s.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.movie.ui.message.ChatActivity.java

/**
 * ?/*from   w  w w  . j a  v a 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(),
            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.ximai.savingsmore.save.activity.AddGoodsAcitivyt.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (resultCode != RESULT_OK) {
        return;/*from   w  w w  .j a  v  a2 s .c  om*/
    } else if (requestCode == PICK_FROM_CAMERA || requestCode == PICK_FROM_IMAGE) {

        Uri uri = null;
        if (null != intent && intent.getData() != null) {
            uri = intent.getData();
        } else {
            String fileName = PreferencesUtils.getString(this, "tempName");
            uri = Uri.fromFile(new File(FileSystem.getCachesDir(this, true).getAbsolutePath(), fileName));
        }

        if (uri != null) {
            cropImage(uri, CROP_PHOTO_CODE);
        }
    } else if (requestCode == CROP_PHOTO_CODE) {
        Uri photoUri = intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT);
        try {
            upLoadImage(new File((new URI(photoUri.toString()))), "BusinessLicense");
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        //addImage(imagePath);

    }
}

From source file:com.easemob.appstoremedical.activity.ChatActivity.java

/**
 * ?// ww  w .  j  a v a2 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

/**
 * ?//from ww w . j a v a  2 s .  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

/**
 * ?/*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);
        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);
}

From source file:com.zmyh.r.easemob.activitys.ChatActivity.java

/**
 * ?//from  ww  w .j  av  a  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, Toast.LENGTH_LONG).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:cn.ucai.SuperWechat.activity.ChatActivity.java

/**
 * ?/*  w  ww. ja  v a 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(),
            SuperWeChatApplication.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);
}