List of usage examples for android.provider MediaStore EXTRA_OUTPUT
String EXTRA_OUTPUT
To view the source code for android.provider MediaStore EXTRA_OUTPUT.
Click Source Link
From source file:com.mobicage.rogerthat.plugins.messaging.widgets.PhotoUploadWidget.java
@Override public void initializeWidget() { mImagePreview = (ImageView) findViewById(R.id.image_preview); mSourceButton = (Button) findViewById(R.id.select_picture); mSourceButton.setText(R.string.get_picture); mPhotoSelected = false;// w ww. j a v a 2s. c om mRatio = (String) mWidgetMap.get("ratio"); mQuality = (String) mWidgetMap.get("quality"); mSourceButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final SafeRunnable runnableContinue = new SafeRunnable() { @Override protected void safeRun() throws Exception { getPicture(); } }; final SafeRunnable runnableCheckStorage = new SafeRunnable() { @Override protected void safeRun() throws Exception { if (mActivity.askPermissionIfNeeded(Manifest.permission.WRITE_EXTERNAL_STORAGE, ServiceMessageDetailActivity.PERMISSION_REQUEST_PHOTO_UPLOAD_WIDGET, runnableContinue, mActivity.showMandatoryPermissionPopup(mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE))) return; runnableContinue.run(); } }; if (TRUE.equals(mWidgetMap.get("camera"))) { if (mActivity.askPermissionIfNeeded(Manifest.permission.CAMERA, ServiceMessageDetailActivity.PERMISSION_REQUEST_PHOTO_UPLOAD_WIDGET, runnableCheckStorage, mActivity.showMandatoryPermissionPopup(mActivity, Manifest.permission.CAMERA))) return; } runnableCheckStorage.run(); } private void getPicture() { File image; try { image = getTmpUploadPhotoLocation(); } catch (IOException e) { L.d(e.getMessage()); UIUtils.showLongToast(getContext(), e.getMessage()); return; } mUriSavedImage = Uri.fromFile(image); Intent cameraIntent = null; boolean hasCamera = mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA); boolean hasCameraPermission = mActivity.getMainService().isPermitted(Manifest.permission.CAMERA); if (hasCamera && hasCameraPermission) { cameraIntent = ActivityUtils.buildTakePictureIntent(mActivity, mUriSavedImage, Facing.BACK); } Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); galleryIntent.putExtra(MediaStore.EXTRA_OUTPUT, mUriSavedImage); galleryIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); galleryIntent.setType("image/*"); final Intent chooserIntent; if (TRUE.equals(mWidgetMap.get("gallery")) && TRUE.equals(mWidgetMap.get("camera"))) { chooserIntent = Intent.createChooser(galleryIntent, mActivity.getString(R.string.select_source)); if (cameraIntent != null) { chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { cameraIntent }); } mActivity.startActivityForResult(chooserIntent, PICK_IMAGE); } else if (TRUE.equals(mWidgetMap.get("gallery"))) { chooserIntent = Intent.createChooser(galleryIntent, mActivity.getString(R.string.select_source)); mActivity.startActivityForResult(chooserIntent, PICK_IMAGE); } else if (TRUE.equals(mWidgetMap.get("camera"))) { if (cameraIntent != null) { mActivity.startActivityForResult(cameraIntent, PICK_IMAGE); } else if (!hasCamera) { UIUtils.showDialog(mActivity, R.string.no_camera_available_title, R.string.no_camera_available); } else if (!hasCameraPermission) { String title = mActivity.getString(R.string.need_camera_permission_title); String message = mActivity.getString(R.string.need_camera_permission); SafeDialogClick onPositiveClick = new SafeDialogClick() { @Override public void safeOnClick(DialogInterface dialog, int id) { dialog.dismiss(); Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", mActivity.getPackageName(), null); intent.setData(uri); mActivity.startActivity(intent); } }; UIUtils.showDialog(mActivity, title, message, R.string.go_to_app_settings, onPositiveClick, R.string.cancel, null); } } } }); }
From source file:com.business.rushour.businessapp.TabOwnerRegistrationActivity.java
public void captureImage(View view) { final CharSequence[] options = { "Take Photo", "Choose from Gallery", "Cancel" }; AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()); builder.setTitle("Add Photo!"); builder.setItems(options, new DialogInterface.OnClickListener() { @Override//from www.j a v a 2 s .c o m public void onClick(DialogInterface dialog, int item) { if (options[item].equals("Take Photo")) { try { final Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); //startActivityForResult(cameraIntent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE); fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // start the image capture Intent startActivityForResult(cameraIntent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE); } catch (ActivityNotFoundException anfe) { String errorMessage = "Whoops - your device doesn't support capturing images!"; //Toast toast = Toast.makeText(view.getContext(), errorMessage, Toast.LENGTH_SHORT); //toast.show(); } } else if (options[item].equals("Choose from Gallery")) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(intent, PICK_IMAGE_REQUEST); } else if (options[item].equals("Cancel")) { dialog.dismiss(); } } }); builder.show(); }
From source file:com.qjdchina.qjdsale.MemberPicturePlusFragment.java
private void startCamera(String folder, String file) { if (Utils.isHasSdcard()) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File imgFolder = new File(folder); if (!imgFolder.exists()) { imgFolder.mkdirs();/*from w ww . j av a2s.co m*/ } File imgFile = new File(folder, file); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imgFile)); startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE); } else { Toast.makeText(getActivity(), "SD?", Toast.LENGTH_SHORT).show(); } }
From source file:com.Jsu.framework.image.imageChooser.ImageChooserManager.java
private String takePicture() throws ChooserException { checkDirectory();//from w ww . java 2 s .co m try { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); filePathOriginal = buildFilePathOriginal(foldername, "jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, buildCaptureUri(filePathOriginal)); if (extras != null) { intent.putExtras(extras); } startActivity(intent); } catch (ActivityNotFoundException e) { throw new ChooserException(e); } return filePathOriginal; }
From source file:com.amytech.android.library.views.imagechooser.api.ImageChooserManager.java
private String takePicture() throws Exception { checkDirectory();/*from ww w . j a v a 2 s .co m*/ try { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); filePathOriginal = FileUtils.getDirectory(foldername) + File.separator + Calendar.getInstance().getTimeInMillis() + ".jpg"; intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(filePathOriginal))); if (extras != null) { intent.putExtras(extras); } startActivity(intent); } catch (ActivityNotFoundException e) { throw new Exception("Activity not found"); } return filePathOriginal; }
From source file:com.wit.android.support.content.intent.VideoIntent.java
/** *///from ww w . j a va 2s .c o m @Override public VideoIntent withDefaultProviders() { withProviders( new ContentProviderItem().name("Gallery").intent(createGalleryIntent()) .requestCode(REQUEST_CODE_GALLERY), mCameraProvider = new ContentProviderItem().name("Camera").intent(createCameraIntent()) .requestCode(REQUEST_CODE_CAMERA)); if (mUri != null) { mCameraProvider.intent.putExtra(MediaStore.EXTRA_OUTPUT, mUri); } return this; }
From source file:com.example.shinelon.ocrcamera.MainActivity.java
public void crop(Uri uri) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); startActivityForResult(intent, CROP); setImage(uri);//from ww w . ja v a 2 s. c o m mCropButton.setEnabled(true); }
From source file:com.commonsware.cwac.cam2.support.CameraActivity.java
private Uri getOutputUri() { Uri output = null;/*from w w w .ja va 2 s . co m*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { ClipData clipData = getIntent().getClipData(); if (clipData != null && clipData.getItemCount() > 0) { output = clipData.getItemAt(0).getUri(); } } if (output == null) { output = getIntent().getParcelableExtra(MediaStore.EXTRA_OUTPUT); } return (output); }
From source file:com.renard.ocr.BaseDocumentActivitiy.java
protected void startCamera() { try {//from w w w . j a v a2 s.co m cameraPicUri = null; dateCameraIntentStarted = new Date(); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File image = null; try { if (!storageDir.exists()) { storageDir.mkdirs(); } image = new File(storageDir, imageFileName + ".jpg"); if (image.exists()) { image.createNewFile(); } cameraPicUri = Uri.fromFile(image); intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraPicUri); startActivityForResult(intent, REQUEST_CODE_MAKE_PHOTO); } catch (IOException e) { showFileError(PixLoadStatus.IO_ERROR); } } catch (ActivityNotFoundException e) { showFileError(PixLoadStatus.CAMERA_APP_NOT_FOUND); } }