List of usage examples for android.provider MediaStore ACTION_IMAGE_CAPTURE
String ACTION_IMAGE_CAPTURE
To view the source code for android.provider MediaStore ACTION_IMAGE_CAPTURE.
Click Source Link
From source file:Main.java
public static Intent getIntentForAction(int action) { Log.d(TAG, "[AirImagePickerUtils] Entering getIntentForAction"); Intent intent;//from w w w . j a va 2s . c o m switch (action) { case GALLERY_IMAGES_ONLY_ACTION: intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction"); return intent; case GALLERY_VIDEOS_ONLY_ACTION: intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("video/*"); Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction"); return intent; case CAMERA_IMAGE_ACTION: Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction"); return new Intent(MediaStore.ACTION_IMAGE_CAPTURE); case CAMERA_VIDEO_ACTION: Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction"); return new Intent(MediaStore.ACTION_VIDEO_CAPTURE); case CROP_ACTION: Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction"); return new Intent("com.android.camera.action.CROP"); default: Log.d(TAG, "[AirImagePickerUtils] Exiting getIntentForAction"); return null; } }
From source file:com.example.CuriosityActivity.java
public void takeAndSharePhoto(View view) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); final File f = new File(Environment.getExternalStorageDirectory(), PIC_FILENAME); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); startActivityForResult(intent, IMAGE_REQUEST); }
From source file:com.fuck_boilerplate.rx_paparazzo.interactors.TakePhoto.java
private Intent getIntentCamera(Uri uri) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.addFlags(READ_WRITE_PERMISSIONS); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); grantFileReadWritePermissions(intent, uri); return intent; }
From source file:net.bluehack.ui.Components.AvatarUpdater.java
public void openCamera() { try {/*w w w. j a v a 2s . c o m*/ Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File image = AndroidUtilities.generatePicturePath(); if (image != null) { if (Build.VERSION.SDK_INT >= 24) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile( parentFragment.getParentActivity(), BuildConfig.APPLICATION_ID + ".provider", image)); takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image)); } currentPicturePath = image.getAbsolutePath(); } parentFragment.startActivityForResult(takePictureIntent, 13); } catch (Exception e) { FileLog.e("tmessages", e); } }
From source file:kr.wdream.ui.Components.AvatarUpdater.java
public void openCamera() { try {/*w w w. ja va2 s .c o m*/ Log.d("AvatarUpdater", "openCamera"); Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File image = AndroidUtilities.generatePicturePath(); if (image != null) { if (Build.VERSION.SDK_INT >= 24) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile( parentFragment.getParentActivity(), BuildConfig.APPLICATION_ID + ".provider", image)); takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image)); } currentPicturePath = image.getAbsolutePath(); } parentFragment.startActivityForResult(takePictureIntent, 13); } catch (Exception e) { FileLog.e("tmessages", e); } }
From source file:com.snapshotshopper.EditItemEntry.java
public void callCamera(View view) { //Call the camera Intent cameraintent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(cameraintent, 0); }
From source file:com.tanlet.picture.PictureFragment.java
private void doTakePhotoAction() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); mImageCaptureUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "annotationDemo" + String.valueOf(System.currentTimeMillis()) + ".jpg")); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mImageCaptureUri); try {/* w ww . j a va2 s . c om*/ intent.putExtra("return-data", false); startActivityForResult(intent, 10086); } catch (ActivityNotFoundException e) { e.printStackTrace(); } }
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/*from w w w . ja v a 2 s . c o m*/ 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.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;//www . ja v a 2s .com 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:disono.webmons.com.utilities.sensor.Camera.Launcher.java
public Intent takeIntentPicture() { return new Intent(MediaStore.ACTION_IMAGE_CAPTURE); }