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:io.v.moments.ux.MainActivity.java
/** * Before calling this, must have permission to read/write to storage, to * read/write photo data. Don't need camera permission, since a new activity * is started to actually take the photo. *//* w ww . j a v a 2 s.c o m*/ private void takePhoto() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); mCurrentPhotoId = Id.makeRandom(); Integer ordinal = mLocalMoments.size() + 1; Uri uri = mBitMapper.getCameraPhotoUri(ordinal); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); startActivityForResult(intent, RequestCode.CAPTURE_IMAGE); }
From source file:cn.com.caronwer.activity.CertificationActivity.java
@Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { switch (requestCode) { case 100: {/*from w ww .j a v a 2 s .c om*/ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent takeIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //???? takeIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri .fromFile(new File(Environment.getExternalStorageDirectory(), IMAGE_FILE_NAME[imgType]))); startActivityForResult(takeIntent, REQUESTCODE_TAKE); } else { Toast.makeText(CertificationActivity.this, "Permission Denied", Toast.LENGTH_SHORT).show(); } return; } case 200: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { Intent pickIntent = new Intent(Intent.ACTION_PICK, null); pickIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); startActivityForResult(pickIntent, REQUESTCODE_PICK); } else { Toast.makeText(CertificationActivity.this, "Permission Denied", Toast.LENGTH_SHORT).show(); } return; } case 300: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { //getServletData(); } else { Toast.makeText(CertificationActivity.this, "Permission Denied", Toast.LENGTH_SHORT).show(); } return; } } super.onRequestPermissionsResult(requestCode, permissions, grantResults); }
From source file:com.liwn.zzl.markbit.DrawOptionsMenuActivity.java
protected void takePhoto() { File tempFile = FileIO.createNewEmptyPictureFile(DrawOptionsMenuActivity.this, FileIO.getDefaultFileName()); if (tempFile != null) { mCameraImageUri = Uri.fromFile(tempFile); }//from w w w . j a va 2 s. c o m if (mCameraImageUri == null) { new InfoDialog(DialogType.WARNING, R.string.dialog_error_sdcard_text, R.string.dialog_error_save_title) .show(getSupportFragmentManager(), "savedialogerror"); return; } // Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCameraImageUri); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE); // intent.putExtra(MediaStore.EXTRA_OUTPUT, mCameraImageUri); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); // startActivityForResult(intent, REQUEST_CODE_TAKE_PICTURE); }
From source file:com.lcl6.cn.imagepickerl.AndroidImagePicker.java
/** * take picture// w w w .j av a2s . c o m */ public void takePicture(Activity act, int requestCode) throws IOException { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(act.getPackageManager()) != null) { // Create the File where the photo should go //File photoFile = createImageFile(); File photoFile = createImageSaveFile(act); // Continue only if the File was successfully created if (photoFile != null) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } } act.startActivityForResult(takePictureIntent, requestCode); }
From source file:com.fvd.nimbus.MainActivity.java
public void getPhoto() { try {/*from w ww . j a v a 2s . c o m*/ photoFileName = String.valueOf(System.currentTimeMillis()) + "-tmp.jpg"; Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File file = new File(appSettings.getInstance().SavingPath, photoFileName); outputFileUri = Uri.fromFile(file); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(intent, TAKE_PHOTO); //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up ); overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out); } catch (Exception e) { appSettings.appendLog("main:getPhoto " + e.getMessage()); } }
From source file:bmcx.aiton.com.passenger.view.activity.UploadUserDataActivity.java
/** * ?/*from w ww. j a va2 s .c om*/ */ private void setIntentParams(Intent intent) { intent.putExtra("crop", "true"); intent.putExtra("aspectX", 3); intent.putExtra("aspectY", 2); intent.putExtra("outputX", 300); intent.putExtra("outputY", 200); intent.putExtra("noFaceDetection", true); // no face detection intent.putExtra("scale", true); intent.putExtra("return-data", false); intent.putExtra(MediaStore.EXTRA_OUTPUT, mPhotoUri); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); }
From source file:com.pawnua.android.app.gpstrips.activities.TripDetailActivity.java
private void takePhoto() { Intent callCameraApplicationIntent = new Intent(); callCameraApplicationIntent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); try {/*from w w w . j a v a 2s .c om*/ photoFile = GalleryDataManager.createImageFile(mGalleryFolder); } catch (IOException e) { e.printStackTrace(); } callCameraApplicationIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); startActivityForResult(callCameraApplicationIntent, ACTIVITY_START_CAMERA_APP); }
From source file:com.cordova.photo.CameraLauncher.java
/** * Get image from photo library./*from w w w.j av a2 s . c o m*/ * * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param srcType The album to get image from. * @param returnType Set the type of image to return. * @param encodingType */ // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do! // TODO: Images from kitkat filechooser not going into crop function public void getImage(int srcType, int returnType, int encodingType) { Intent intent = new Intent(); String title = GET_PICTURE; croppedUri = null; if (this.mediaType == PICTURE) { intent.setType("image/*"); if (this.allowEdit) { intent.setAction(Intent.ACTION_PICK); intent.putExtra("crop", "true"); if (targetWidth > 0) { intent.putExtra("outputX", targetWidth); } if (targetHeight > 0) { intent.putExtra("outputY", targetHeight); } if (targetHeight > 0 && targetWidth > 0 && targetWidth == targetHeight) { intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); } File photo = createCaptureFile(encodingType); croppedUri = Uri.fromFile(photo); intent.putExtra(MediaStore.EXTRA_OUTPUT, croppedUri); } else { intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } } else if (this.mediaType == VIDEO) { intent.setType("video/*"); title = GET_VIDEO; intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } else if (this.mediaType == ALLMEDIA) { // I wanted to make the type 'image/*, video/*' but this does not work on all versions // of android so I had to go with the wildcard search. intent.setType("*/*"); title = GET_All; intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } if (this.activity != null) { this.activity.startActivityForResult(Intent.createChooser(intent, new String(title)), (srcType + 1) * 16 + returnType + 1); } }
From source file:com.grass.caishi.cc.activity.RegisterActivity.java
/** * ?//from w ww . jav a 2 s . c om */ public void selectPicFromCamera() { // cameraFile = new File(PathUtil.getInstance().getImagePath(), // DemoApplication.getInstance().getUserName() startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraFile)), USERPIC_REQUEST_CODE_CAMERA); }
From source file:com.dycode.jepretstory.mediachooser.activity.HomeFragmentActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemID = item.getItemId(); if (itemID == android.R.id.home) { materialMenu.animateTouch();//w ww. j av a 2 s . c o m finish(); } else if (itemID == R.id.menuNext) { //android.support.v4.app.FragmentManager fragmentManager = getSupportFragmentManager(); if (mVideoFragment != null || mImageFragment != null) { if (mVideoFragment != null) { if (mVideoFragment.getSelectedVideos() != null && mVideoFragment.getSelectedVideos().size() > 0) { Intent videoIntent = new Intent(); videoIntent.setAction(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER); //videoIntent.putStringArrayListExtra("list", mVideoFragment.getSelectedVideoList()); videoIntent.putParcelableArrayListExtra("selectedVideos", mVideoFragment.getSelectedVideos()); setResult(RESULT_OK, videoIntent); sendBroadcast(videoIntent); } } if (mImageFragment != null) { if (mImageFragment.getSelectedImages() != null && mImageFragment.getSelectedImages().size() > 0) { Intent imageIntent = new Intent(); imageIntent.setAction(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER); //imageIntent.putStringArrayListExtra("list", mImageFragment.getSelectedImageList()); imageIntent.putParcelableArrayListExtra("selectedImages", mImageFragment.getSelectedImages()); setResult(RESULT_OK, imageIntent); sendBroadcast(imageIntent); } } finish(); } else { Toast.makeText(HomeFragmentActivity.this, getString(R.string.plaese_select_file), Toast.LENGTH_SHORT).show(); } } else if (itemID == R.id.menuCamera) { if (currentMediaMode == MediaType.VIDEO) { Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); fileUri = getOutputMediaFileUri(MediaType.VIDEO); // create a file to save the image intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0); Long limit = Long.valueOf((MediaChooserConstants.SELECTED_VIDEO_SIZE_IN_MB * 1024 * 1024)); intent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, limit); intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, MediaChooserConstants.VIDEO_DURATION_LIMIT_IN_SECOND); // start the image capture Intent startActivityForResult(intent, MediaChooserConstants.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE); } else { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri = getOutputMediaFileUri(MediaType.IMAGE); // create a file to save the image intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name // start the image capture Intent startActivityForResult(intent, MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } } return super.onOptionsItemSelected(item); }