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.safeness.im.activity.ChatActivity.java
/** * ?//w w w . ja va2 s . com */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { Toast.makeText(getApplicationContext(), "SD????", Toast.LENGTH_SHORT).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), PatientApplication.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.futurologeek.smartcrossing.crop.CropImageActivity.java
private void setResultUri(Uri uri) { setResult(RESULT_OK, new Intent().putExtra(MediaStore.EXTRA_OUTPUT, uri)); }
From source file:net.gsantner.opoc.util.ShareUtil.java
/** * Request a picture from camera-like apps * Result ({@link String}) will be available from {@link Activity#onActivityResult(int, int, Intent)}. * It has set resultCode to {@link Activity#RESULT_OK} with same requestCode, if successfully * The requested image savepath has to be stored at caller side (not contained in intent), * it can be retrieved using {@link #extractResultFromActivityResult(int, int, Intent)}, * returns null if an error happened.//from w w w . ja va 2s . com * * @param target Path to file to write to, if folder the filename gets app_name + millis + random filename. If null DCIM folder is used. */ public String requestCameraPicture(File target) { if (!(_context instanceof Activity)) { throw new RuntimeException("Error: ShareUtil.requestCameraPicture needs an Activity Context."); } String cameraPictureFilepath = null; Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(_context.getPackageManager()) != null) { File photoFile; try { // Create an image file name if (target != null && !target.isDirectory()) { photoFile = target; } else { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH-mm-ss", Locale.getDefault()); File storageDir = target != null ? target : new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "Camera"); String imageFileName = ((new ContextUtils(_context).rstr("app_name")) .replaceAll("[^a-zA-Z0-9\\.\\-]", "_") + "_").replace("__", "_") + sdf.format(new Date()); photoFile = new File(storageDir, imageFileName + ".jpg"); if (!photoFile.getParentFile().exists() && !photoFile.getParentFile().mkdirs()) { photoFile = File.createTempFile(imageFileName + "_", ".jpg", storageDir); } } //noinspection StatementWithEmptyBody if (!photoFile.getParentFile().exists() && photoFile.getParentFile().mkdirs()) ; // Save a file: path for use with ACTION_VIEW intents cameraPictureFilepath = photoFile.getAbsolutePath(); } catch (IOException ex) { return null; } // Continue only if the File was successfully created if (photoFile != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { Uri uri = FileProvider.getUriForFile(_context, getFileProviderAuthority(), photoFile); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri); } else { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } ((Activity) _context).startActivityForResult(takePictureIntent, REQUEST_CAMERA_PICTURE); } } _lastCameraPictureFilepath = cameraPictureFilepath; return cameraPictureFilepath; }
From source file:com.tt.jobtracker.MainActivity.java
@Override public void onTaskLineItemPhotoClickInitiated(TaskLineItemViewModel taskLineItemViewModel) { tlvm = taskLineItemViewModel;/*from w w w . j a va2 s . c om*/ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); fileUri = CameraHelper.getOutputMediaFileUri(CameraHelper.MEDIA_TYPE_IMAGE); // create intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the startActivityForResult(intent, CAPTURE_TASKLINEITEM_IMAGE_ACTIVITY_REQUEST_CODE); }
From source file:com.easemob.ui.ChatActivity.java
/** * ?/*from ww w. j a v a 2 s . c o m*/ */ public void selectVideoFromCamera() { if (!CommonUtils.isExitsSdcard()) { Toast.makeText(getApplicationContext(), "SD????", 0).show(); return; } videoFile = new File(PathUtil.getInstance().getVideoPath(), MyApplication.getInstance().getUserName() + System.currentTimeMillis() + ".mp4"); videoFile.getParentFile().mkdirs(); startActivityForResult(new Intent(MediaStore.ACTION_VIDEO_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(videoFile)), REQUEST_CODE_CAMERA_VIDEO); }
From source file:com.kaixin.android.activity.ChatActivity.java
/** * ?/*from ww w .j av a 2s. com*/ */ public void selectPicFromCamera() { /*if(!CommonUtils.isExitsSdcard()){ Toast.makeText(getApplicationContext(), "SD????", 0).show(); return; }*/ cameraFile = new File(PathUtil.getInstance().getImagePath(), StorageUtil.getString(this, "username") + 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:app.view.chat.ChatActivity.java
/** * ?//from w w w. j a v a2 s . co m */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { Toast.makeText(getApplicationContext(), "SD????", Toast.LENGTH_SHORT).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:niltor.net.chatuidemo.activity.ChatActivity.java
/** * ?/*from ww w . j a va2 s.c o m*/ */ public void selectPicFromCamera() { if (!CommonUtils.isExitsSdcard()) { Toast.makeText(getApplicationContext(), "SD????", Toast.LENGTH_SHORT).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.blueshit.activity.ChatActivity.java
/** * ?//from w ww . j a v 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, Toast.LENGTH_SHORT).show(); return; } cameraFile = new File(PathUtil.getInstance().getImagePath(), Application.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.SettingsFragmentC_0815.java
/** * ?/*from w ww.ja va 2s .c o m*/ */ public void selectPicFromLocal() { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); //Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null); intent.setType("image/*"); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); intent.putExtra("outputX", 600); intent.putExtra("outputY", 600); intent.putExtra("scale", true); intent.putExtra("return-data", false); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUritest); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); intent.putExtra("noFaceDetection", true); // no face detection //startActivityForResult(intent, CHOOSE_BIG_PICTURE); startActivityForResult(intent, USERPIC_REQUEST_CODE_LOCAL); } else { intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, USERPIC_REQUEST_CODE_LOCAL_19); } /*//??? cutFile = new File(PathUtil.getInstance().getImagePath(), DemoApplication.getInstance().getUser() + System.currentTimeMillis() + "_m.jpg"); cutFile.getParentFile().mkdirs();*/ }