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.ysls.imhere.ChatActivity.java

/**
 * ?/*from w w w. ja  v a 2 s. c om*/
 */
public void selectPicFromCamera() {
    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.ximai.savingsmore.save.activity.FourStepRegisterActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (resultCode != RESULT_OK) {
        return;//w  ww  . ja  v a 2 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);
        if (isslinece) {
            MyImageLoader.displayDefaultImage("file://" + photoUri.getPath(), slience_image);
            zhizhao_path = photoUri.toString();
            try {
                upLoadImage(new File((new URI(photoUri.toString()))), "BusinessLicense");
            } catch (URISyntaxException e) {
                e.printStackTrace();
            }
        } else if (isZhengshu) {
            MyImageLoader.displayDefaultImage("file://" + photoUri.getPath(), zhengshu_iamge);
            xukezheng_path = photoUri.toString();
            try {
                upLoadImage(new File((new URI(photoUri.toString()))), "LicenseKey");
            } catch (URISyntaxException e) {
                e.printStackTrace();
            }

            //upLoadImage(new File((new URI(photoUri.toString()))), "Photo");
        } else if (isItem) {
            if (images.size() < 10) {
                shangpu_path.add(photoUri.toString());
                try {
                    upLoadImage(new File((new URI(photoUri.toString()))), "Seller");
                } catch (URISyntaxException e) {
                    e.printStackTrace();
                }
            } else {
                Toast.makeText(FourStepRegisterActivity.this, "?9",
                        Toast.LENGTH_SHORT).show();
            }
        }
        //addImage(imagePath);
    }
}

From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_communicator.util.FileUtils.java

public static void recordVideo(Context ctx, Uri mFileCaptureUri) {
    if (!isIntentAvailable(ctx, MediaStore.ACTION_VIDEO_CAPTURE)) {
        log.warn("Cannot record video (Intent is not available)");
        return;//from ww  w  . ja v  a  2 s.  c  om
    }

    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mFileCaptureUri);

    int durationLimit = ctx.getResources().getInteger(R.integer.video_recording_duration_limit);
    if (durationLimit > 0) {
        takeVideoIntent.putExtra("android.intent.extra.durationLimit", durationLimit);
    }

    try {
        ((Activity) ctx).startActivityForResult(takeVideoIntent, AppUtils.ACTION_RECORD_VIDEO);
    } catch (ActivityNotFoundException e) {
        log.warn("Cannot record video", e);
    }
}

From source file:com.fabernovel.alertevoirie.ReportDetailsActivity.java

private void takePicture(int type, int RequestCode) {
    // Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    File tmpFile = null;/*from  w ww  .j a v a 2  s.c o m*/
    try {
        tmpFile = File.createTempFile("capture", ".tmp");
    } catch (IOException e) {
        e.printStackTrace();
    }

    Intent camIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    uriOfPicFromCamera = Uri.fromFile(tmpFile);
    camIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriOfPicFromCamera);

    Intent gallIntent = new Intent();
    gallIntent.setType("image/*");
    gallIntent.setAction(Intent.ACTION_GET_CONTENT);

    if (type == 0) {
        ReportDetailsActivity.this.startActivityForResult(camIntent, RequestCode);
    } else if (type == 1) {
        ReportDetailsActivity.this.startActivityForResult(Intent.createChooser(gallIntent, "Galerie photo"),
                RequestCode);
    }
    // startActivityForResult(intent, v.getId());

}

From source file:de.azapps.mirakel.main_activity.tasks_fragment.TasksFragment.java

public void updateButtons() {
    // a) Android 2.3 dosen't support speech toText
    // b) The user can switch off the button
    if (this.view == null) {
        return;//from w ww .j a v  a 2s . c o  m
    }
    if (android.os.Build.VERSION.SDK_INT <= android.os.Build.VERSION_CODES.HONEYCOMB
            || !MirakelCommonPreferences.useBtnSpeak()) {
        this.view.findViewById(R.id.btnSpeak_tasks).setVisibility(View.GONE);
    } else {
        final ImageButton btnSpeak = (ImageButton) this.view.findViewById(R.id.btnSpeak_tasks);
        // txtText = newTask;
        btnSpeak.setVisibility(View.VISIBLE);
        btnSpeak.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                final Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
                intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
                        TasksFragment.this.main.getString(R.string.speak_lang_code));
                try {
                    getActivity().startActivityForResult(intent, MainActivity.RESULT_SPEECH);
                    TasksFragment.this.newTask.setText("");
                } catch (final ActivityNotFoundException a) {
                    ErrorReporter.report(ErrorType.NO_SPEACH_RECOGNITION);
                }
            }
        });
    }
    if (!MirakelCommonPreferences.useBtnAudioRecord()) {
        this.view.findViewById(R.id.btnAudio_tasks).setVisibility(View.GONE);
    } else {
        final ImageButton btnAudio = (ImageButton) this.view.findViewById(R.id.btnAudio_tasks);
        btnAudio.setVisibility(View.VISIBLE);
        btnAudio.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(final View v) {
                // TODO BAHHHH this is ugly!
                final Task task = Task.getDummy(getActivity(), TasksFragment.this.main.getCurrentList());
                TaskDialogHelpers.handleAudioRecord(TasksFragment.this.main, task, new ExecInterfaceWithTask() {
                    @Override
                    public void exec(final Task t) {
                        TasksFragment.this.main.setCurrentList(t.getList());
                        TasksFragment.this.main.setCurrentTask(t, true);
                    }
                });
            }
        });
    }
    if (!MirakelCommonPreferences.useBtnCamera()
            || !Helpers.isIntentAvailable(this.main, MediaStore.ACTION_IMAGE_CAPTURE)) {
        this.view.findViewById(R.id.btnCamera).setVisibility(View.GONE);
    } else {
        final ImageButton btnCamera = (ImageButton) this.view.findViewById(R.id.btnCamera);
        btnCamera.setVisibility(View.VISIBLE);
        btnCamera.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(final View v) {
                try {
                    final Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                    final Uri fileUri = FileUtils.getOutputMediaFileUri(FileUtils.MEDIA_TYPE_IMAGE);
                    if (fileUri == null) {
                        return;
                    }
                    TasksFragment.this.main.setFileUri(fileUri);
                    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
                    getActivity().startActivityForResult(cameraIntent, MainActivity.RESULT_CAMERA);
                } catch (final ActivityNotFoundException a) {
                    ErrorReporter.report(ErrorType.PHOTO_NO_CAMERA);
                } catch (final IOException e) {
                    if (e.getMessage().equals(FileUtils.ERROR_NO_MEDIA_DIR)) {
                        ErrorReporter.report(ErrorType.PHOTO_NO_MEDIA_DIRECTORY);
                    }
                }
            }
        });
    }
}

From source file:com.abc.driver.PersonalActivity.java

/**
 * start to take picture/*from  w  w  w . j a v a2  s . c om*/
 */
private void startToCameraActivity(int requestId) {
    Intent localIntent = new Intent("android.media.action.IMAGE_CAPTURE");

    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    File mediaFile = new File(app.regUserPath + File.separator + "IMG_" + timeStamp + ".png");
    localIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mediaFile));
    imageUri = Uri.fromFile(mediaFile);

    // isCameraCapture = true;

    startActivityForResult(localIntent, requestId);
}

From source file:com.just.agentweb.AgentWebUtils.java

static Intent getIntentCaptureCompat(Context context, File file) {
    Intent mIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    Uri mUri = getUriFromFile(context, file);
    mIntent.addCategory(Intent.CATEGORY_DEFAULT);
    mIntent.putExtra(MediaStore.EXTRA_OUTPUT, mUri);
    return mIntent;
}

From source file:com.sim2dial.dialer.ChatFragment.java

private void pickImage() {
    final List<Intent> cameraIntents = new ArrayList<Intent>();
    final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    File file = new File(Environment.getExternalStorageDirectory(), getString(R.string.temp_photo_name));
    imageToUploadUri = Uri.fromFile(file);
    captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageToUploadUri);
    cameraIntents.add(captureIntent);/*from w  ww.ja v a 2s  . c  o  m*/

    final Intent galleryIntent = new Intent();
    galleryIntent.setType("image/*");
    galleryIntent.setAction(Intent.ACTION_GET_CONTENT);

    final Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.image_picker_title));
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {}));

    startActivityForResult(chooserIntent, ADD_PHOTO);
}

From source file:com.indoorsy.frash.easemob.activity.ChatActivity.java

/**
 * ?// w  w w  .j av  a2 s . c  om
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        ToastUtil.toast(getApplicationContext(), R.string.sd_not_find);
        return;
    }
    cameraFile = new File(PathUtil.getInstance().getImagePath(), 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.example.bidisha.ace.ClueScan.java

private void takePicture() {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    File photo = new File(Environment.getExternalStorageDirectory(), "picture1.jpg");
    // imageUri = Uri.fromFile(photo);
    imageUri = FileProvider.getUriForFile(ClueScan.this, BuildConfig.APPLICATION_ID + ".provider", photo);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
    startActivityForResult(intent, PHOTO_REQUEST);
}