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.google.codelabs.cosu.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Setup button which calls intent to camera app to take a picture takePicButton = (Button) findViewById(R.id.pic_button); takePicButton.setOnClickListener(new View.OnClickListener() { @Override/* w ww. j a va 2s . c om*/ public void onClick(View v) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(getPackageManager()) != null) { File photoFile = null; try { photoFile = createImageFile(); } catch (IOException e) { Log.e(FILE_TAG, e.getMessage()); } if (photoFile != null) { intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); startActivityForResult(intent, REQUEST_IMAGE_CAPTURE); } } else { Toast.makeText(getApplicationContext(), R.string.no_camera_apps, Toast.LENGTH_SHORT).show(); } } }); // Retrieve Device Policy Manager so that we can check whether we can // lock to screen later mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); lockTaskButton = (Button) findViewById(R.id.start_lock_button); lockTaskButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mDevicePolicyManager.isLockTaskPermitted(getApplicationContext().getPackageName())) { Intent lockIntent = new Intent(getApplicationContext(), LockedActivity.class); lockIntent.putExtra(EXTRA_FILEPATH, mCurrentPhotoPath); startActivity(lockIntent); finish(); } else { Toast.makeText(getApplicationContext(), R.string.not_lock_whitelisted, Toast.LENGTH_SHORT) .show(); } } }); imageView = (ImageView) findViewById(R.id.main_imageView); // Check to see if permission to access external storage is granted, // and request if not permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE); if (permissionCheck != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE); } }
From source file:com.moinut.picrop.CropIntent.java
/** * Use params to create an intent.//from w w w . j a va2s . c om * @param data The image from other activity back. * @return crop image intent */ public Intent getIntent(Intent data) { Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(data.getData(), "image/*"); intent.putExtra("crop", "true"); if (aspectX != 0) intent.putExtra(ASPECT_X, aspectX); if (aspectY != 0) intent.putExtra(ASPECT_Y, aspectY); if (outputX != 0) intent.putExtra(OUTPUT_X, outputX); if (outputY != 0) intent.putExtra(OUTPUT_Y, outputY); intent.putExtra(SCALE, scale); intent.putExtra(RETURN_DATA, returnData); intent.putExtra(MediaStore.EXTRA_OUTPUT, saveUri); intent.putExtra(OUTPUT_FORMAT, outputFormat); intent.putExtra(NO_FACE_DETECTION, noFaceDetection); return intent; }
From source file:com.xbm.android.matisse.internal.utils.MediaStoreCompat.java
public void dispatchCaptureIntent(Context context, int requestCode) { Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (captureIntent.resolveActivity(context.getPackageManager()) != null) { File photoFile = null;//w w w . j a v a 2 s. c om try { photoFile = createImageFile(); } catch (IOException e) { e.printStackTrace(); } if (photoFile != null) { mCurrentPhotoPath = photoFile.getAbsolutePath(); mCurrentPhotoUri = FileProvider.getUriForFile(mContext.get(), mCaptureStrategy.authority, photoFile); captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCurrentPhotoUri); captureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(captureIntent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo resolveInfo : resInfoList) { String packageName = resolveInfo.activityInfo.packageName; context.grantUriPermission(packageName, mCurrentPhotoUri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION); } } if (mFragment != null) { mFragment.get().startActivityForResult(captureIntent, requestCode); } else { mContext.get().startActivityForResult(captureIntent, requestCode); } } } }
From source file:it.geosolutions.geocollect.android.core.form.action.CameraAction.java
@Override public void performAction(SherlockFragment fragment, FormAction action, Mission m, Page p) { String originIDString = MissionUtils.getMissionGCID(m); if (originIDString == null || originIDString.isEmpty()) { Log.w("CameraAction", "Could not start intent, feature id not found"); return;//from w ww. ja va 2s. co m } // create Intent to take a picture and return control to the calling application Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uri fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE, originIDString); // create a file to save the image if (fileUri != null) { intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name // start the image capture Intent fragment.startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); } else { Log.w("CameraAction", "Could not start intent, bad Uri"); } }
From source file:com.ultramegasoft.flavordex2.util.PhotoUtils.java
/** * Get an Intent to capture a photo.// w w w. j a v a 2 s . co m * * @return Image capture Intent */ @Nullable public static Intent getTakePhotoIntent(@NonNull Context context) { try { final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final Uri uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".fileprovider", getOutputMediaFile()); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { intent.setClipData(ClipData.newUri(context.getContentResolver(), null, uri)); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } else { final List<ResolveInfo> activities = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo activity : activities) { final String name = activity.activityInfo.packageName; context.grantUriPermission(name, uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } } return intent; } catch (IOException e) { Log.e(TAG, "Failed to create new file", e); } return null; }
From source file:com.waz.zclient.pages.main.conversation.AssetIntentsManager.java
private void captureImage() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); pendingFileUri = getOutputMediaFileUri(IntentType.CAMERA); intent.putExtra(MediaStore.EXTRA_OUTPUT, pendingFileUri); callback.openIntent(intent, IntentType.CAMERA); }
From source file:com.diona.videoplugin.CameraUtil.java
/** * Method to get a video clip./*from w w w. j a v a 2 s. com*/ * * @param fragment * fragment instance that holds the callback method for the camera utility. */ public static void getVideoFromCamera(final Fragment fragment) { callingActivity = fragment; /*final SocialWorkerSharedPreferences preferences = SocialWorkerSharedPreferences.getInstance(); final Intent videoIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE); videoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, preferences.getVideoQuality()); final long videoSize = preferences.getVideoSize(); if (videoSize > 0) { videoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, videoSize); } final int videoDuration = preferences.getVideoDuration(); if (videoDuration > 0) { videoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, videoDuration); } videoIntent.putExtra(MediaStore.EXTRA_OUTPUT, FileCacheUtil.getOutputMediaFileUriForVideos()); callingActivity.startActivityForResult(videoIntent, VIDEO_REQUEST);*/ final Intent videoIntent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE); videoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); //final long videoSize = preferences.getVideoSize(); /* if (videoSize > 0) { videoIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 100); }*/ //final int videoDuration = preferences.getVideoDuration(); /*if (videoDuration > 0) { videoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 60); }*/ videoIntent.putExtra(MediaStore.EXTRA_OUTPUT, FileCacheUtil.getOutputMediaFileUriForVideos()); callingActivity.startActivityForResult(videoIntent, VIDEO_REQUEST); }
From source file:de.damdi.fitness.activity.create_exercise.ImageFragment.java
public void takePhoto(View view) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); File photo = new File(Environment.getExternalStorageDirectory(), "temp_pic.jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); mTempImageUri = Uri.fromFile(photo); startActivityForResult(intent, CreateExerciseActivity.TAKE_PICTURE); }
From source file:com.todoroo.astrid.actfm.ActFmCameraModule.java
public static void showPictureLauncher(final Fragment fragment, final ClearImageCallback clearImageOption) { ArrayList<String> options = new ArrayList<String>(); final Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); PackageManager pm = fragment.getActivity().getPackageManager(); final boolean cameraAvailable = pm.queryIntentActivities(cameraIntent, 0).size() > 0; if (cameraAvailable) options.add(fragment.getString(R.string.actfm_picture_camera)); options.add(fragment.getString(R.string.actfm_picture_gallery)); if (clearImageOption != null) options.add(fragment.getString(R.string.actfm_picture_clear)); ArrayAdapter<String> adapter = new ArrayAdapter<String>(fragment.getActivity(), android.R.layout.simple_spinner_dropdown_item, options.toArray(new String[options.size()])); DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { @SuppressWarnings("nls") @Override//from w ww . j av a 2s.c om public void onClick(DialogInterface d, int which) { if (which == 0 && cameraAvailable) { lastTempFile = getTempFile(fragment.getActivity()); if (lastTempFile != null) cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(lastTempFile)); fragment.startActivityForResult(cameraIntent, REQUEST_CODE_CAMERA); } else if ((which == 1 && cameraAvailable) || (which == 0 && !cameraAvailable)) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); fragment.startActivityForResult( Intent.createChooser(intent, fragment.getString(R.string.actfm_TVA_tag_picture)), REQUEST_CODE_PICTURE); } else { if (clearImageOption != null) clearImageOption.clearImage(); } } }; // show a menu of available options new AlertDialog.Builder(fragment.getActivity()).setAdapter(adapter, listener).show() .setOwnerActivity(fragment.getActivity()); }
From source file:com.allen.mediautil.ImageTakerHelper.java
/** * ?/* w ww .j av a 2 s.co m*/ * <p> * onActivityResult()? */ public static void openCamera(Activity activity, String authority) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.putExtra(MediaStore.EXTRA_OUTPUT, getOutputPictureUri(activity.getApplicationContext(), authority)); activity.startActivityForResult(intent, REQUEST_CAMERA); }