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.nextgis.ngm_clink_monitoring.fragments.CreateObjectFragment.java

protected void showCameraActivity(GISApplication app) {
    Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    // Ensure that there's a camera activity to handle the intent
    if (null != cameraIntent.resolveActivity(getActivity().getPackageManager())) {

        try {//  ww w . j a va 2 s .  c om
            String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(new Date());
            File tempFile = new File(app.getDataDir(),
                    FoclConstants.TEMP_PHOTO_FILE_PREFIX + timeStamp + ".jpg");

            if (!tempFile.exists() && tempFile.createNewFile()
                    || tempFile.exists() && tempFile.delete() && tempFile.createNewFile()) {

                mTempPhotoPath = tempFile.getAbsolutePath();
                Log.d(TAG, "mTempPhotoPath: " + mTempPhotoPath);

                cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tempFile));
                startActivityForResult(cameraIntent, REQUEST_TAKE_PHOTO);
            }

        } catch (IOException e) {
            Toast.makeText(getActivity(), e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        }
    }
}

From source file:dong.lan.tuyi.activity.MainActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.toolbar_community:
        startActivity(new Intent(MainActivity.this, TuyiHomeActivity.class));
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;/*from w  w  w  . ja v  a  2  s .  c o m*/
    case R.id.toolbar_tuyi:
        startActivity(new Intent(MainActivity.this, TuMapActivity.class));
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;
    case R.id.my_Favorite:
        startActivity(new Intent(MainActivity.this, FavoriteActivity.class));
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;
    case R.id.user_des:
        isGetWeather = true;
        break;
    case R.id.offline_tuyi:
        startActivityForResult(new Intent(MainActivity.this, OfflineTuyiActivity.class), 100);
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;
    case R.id.user_community:
        Lock.canPop = false;
        startActivityForResult(new Intent(MainActivity.this, TuyiCommunityActivity.class), 100);
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;
    case R.id.user_head:
        if (Config.tUser == null) {
            Show("????");
            return;
        }
        Lock.canPop = false;
        final Dialog dialog = new AlertDialog.Builder(MainActivity.this).create();
        dialog.setCancelable(true);
        dialog.show();
        dialog.getWindow().setContentView(R.layout.dialog_set_head_img);
        TextView msg = (TextView) dialog.findViewById(R.id.dialog_msg);
        msg.setText("?");
        TextView dialog_left = (TextView) dialog.findViewById(R.id.dialog_left);
        TextView dialog_right = (TextView) dialog.findViewById(R.id.dialog_right);
        dialog_left.setText("");
        dialog_right.setText("");
        dialog_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                File dir = new File(Constant.PICTURE_PATH);
                if (!dir.exists()) {
                    dir.mkdirs();
                }
                // 
                File file = new File(dir,
                        username + "_head_" + new SimpleDateFormat(TimeUtil.FORMAT_NORMAL).format(new Date()));
                filePath = file.getAbsolutePath();// ??
                Uri imageUri = Uri.fromFile(file);

                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
                startActivityForResult(intent, Constant.REQUESTCODE_UPLOADAVATAR_CAMERA);
            }
        });
        dialog_right.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                Intent intent = new Intent(Intent.ACTION_PICK, null);
                intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
                startActivityForResult(intent, Constant.REQUESTCODE_UPLOADAVATAR_LOCATION);
            }
        });

        break;
    case R.id.user_center:
        if (Config.tUser != null) {
            Lock.canPop = false;
            startActivityForResult(
                    new Intent(MainActivity.this, UserCenter.class).putExtra("USER", Config.tUser), 100);
            overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        }
        break;
    case R.id.user_albums:
        startActivityForResult(new Intent(MainActivity.this, TuyiPlayActivity.class), 100);
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;
    case R.id.user_setting:
        startActivityForResult(new Intent(MainActivity.this, MyRadarActivity.class), 100);
        break;
    case R.id.my_interested:
        startActivityForResult(new Intent(MainActivity.this, MyInterestedActivity.class), 100);
        overridePendingTransition(R.anim.slide_in_from_left, R.anim.slide_out_to_right);
        break;

    }
}

From source file:com.youti.chat.activity.ChatActivity.java

/**
 * ?//from  w ww . ja  va  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(),
            YoutiApplication.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.cpic.taylor.logistics.activity.HomeActivity.java

/**
 * //from w w w .ja  v  a2  s. co m
 */
private void getFromCamera(int type1, boolean isUser) {
    intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (isUser) {
        cameraPic = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/userIcon.jpg");
    } else {
        cameraPic = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/carInfo.jpg");
    }

    cameraUri = Uri.fromFile(cameraPic);
    // ???
    intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraUri);
    startActivityForResult(intent, type1);
}

From source file:com.fa.mastodon.activity.ComposeActivity.java

private void initiateCameraApp() {
    // We don't need to ask for permission in this case, because the used calls require
    // android.permission.WRITE_EXTERNAL_STORAGE only on SDKs *older* than Kitkat, which was
    // way before permission dialogues have been introduced.
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (intent.resolveActivity(getPackageManager()) != null) {
        File photoFile = null;//  w  ww.ja v a 2 s . co m
        try {
            photoFile = createNewImageFile();
        } catch (IOException ex) {
            displayTransientError(R.string.error_media_upload_opening);
        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
            photoUploadUri = FileProvider.getUriForFile(this, "com.keylesspalace.tusky.fileprovider",
                    photoFile);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUploadUri);
            startActivityForResult(intent, MEDIA_TAKE_PHOTO_RESULT);
        }
    }
}

From source file:com.inter.trade.ui.fragment.agent.AgentApplyFragmentNew.java

/**
 * ??// w w w  .j a v a  2 s .  c  o m
 */
private void takePhoto() {
    // ??SD??
    String SDState = Environment.getExternalStorageState();
    if (SDState.equals(Environment.MEDIA_MOUNTED)) {

        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);// "android.media.action.IMAGE_CAPTURE"
        /***
         * ????? ?????
         * ?ContentValues?????
         */
        ContentValues values = new ContentValues();
        photoUri = getActivity().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                values);
        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, photoUri);
        /** ----------------- */
        startActivityForResult(intent, SELECT_PIC_BY_TACK_PHOTO);
    } else {
        Toast.makeText(getActivity(), "??", Toast.LENGTH_LONG).show();
    }
}

From source file:cn.ucai.foraging.activity.ChatActivity.java

/**
 * ?/*  w  ww.j  ava  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(),
            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. 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(),
            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

/**
 * ?//from  w  w  w . ja va  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_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:com.ccxt.whl.activity.SettingsFragmentCopy.java

/**
 * ?/*from   w  ww . j a va 2s.co m*/
 * @param uri
 * @param outputX
 * @param outputY
 * @param requestCode
 */
private void cropImageUri(Uri uri, int outputX, int outputY, int requestCode) {
    /*if(getpathfromUri(uri)!=null&&getpathfromUri(imageUri)!=null){
     copyFile(getpathfromUri(uri),getpathfromUri(imageUri));
    }else{
       return;
    }*/
    Log.d("log", uri.toString());
    Intent intent = new Intent("com.android.camera.action.CROP");
    intent.setDataAndType(uri, "image/*");
    intent.putExtra("crop", "true");
    //aspectX aspectY
    intent.putExtra("aspectX", 1);
    intent.putExtra("aspectY", 1);
    // outputX outputY ?
    intent.putExtra("outputX", outputX);
    intent.putExtra("outputY", outputY);
    intent.putExtra("scale", true);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    intent.putExtra("return-data", false);
    intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
    intent.putExtra("noFaceDetection", true); // no face detection
    startActivityForResult(intent, requestCode);
}