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:com.getchute.android.photopickerplus.ui.activity.ServicesActivity.java
@Override public void takePhoto() { if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) { NotificationUtil.makeToast(getApplicationContext(), R.string.toast_feature_camera); return;/*from w w w . j a v a2 s. c om*/ } Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(getPackageManager()) != null) { photoFile = AppUtil.getOutputMediaFile(MediaType.IMAGE); if (photoFile != null) { if (AppUtil.hasImageCaptureBug() == false) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); } startTheCamera(takePictureIntent, Constants.CAMERA_PIC_REQUEST); } } }
From source file:com.collecdoo.fragment.main.RegisterDriverPhotoFragment.java
private void openImageIntent(int uploadIndex) { //EasyImage.openChooserWithGallery(this,"Please choose",0); File imageFile = ImageHelper.createFile(context, "extend_picture.jpg"); String cameraImageFullPath = imageFile.getAbsolutePath(); cameraOutputFileUri = Uri.fromFile(imageFile); // Camera.//from w ww . ja v a 2s . c o m final List<Intent> cameraIntents = new ArrayList<Intent>(); final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final PackageManager packageManager = context.getPackageManager(); final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo res : listCam) { final String packageName = res.activityInfo.packageName; final Intent intent = new Intent(captureIntent); intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); intent.setPackage(packageName); intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraOutputFileUri); cameraIntents.add(intent); } // Filesystem. final Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_PICK); // Chooser of filesystem options. final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source"); // Add the camera options. chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {})); startActivityForResult(chooserIntent, uploadIndex); }
From source file:net.soulwolf.image.picturelib.PictureProcess.java
protected void executeCamera() { this.mCameraPath = new File(mCacheDir, String.format("%s%s", Utils.getTempFileName(), TEMP_FILE_SUFFIX)); if (mCameraPath.exists()) { if (!mCameraPath.delete()) { TLog.e(LOG_TAG, "CameraPath delete failure!"); }/*w w w. j a va 2 s . c om*/ } try { if (!mCameraPath.createNewFile()) { TLog.e(LOG_TAG, "CameraPath create failure!"); } } catch (Exception e) { if (mOnPicturePickListener != null) { mOnPicturePickListener.onError(new FileCreateException(e)); } } Intent intentFromCapture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intentFromCapture.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mCameraPath)); startActivityForResult(intentFromCapture, PictureProcess.CAMERA_REQUEST_CODE); }
From source file:com.app.encontreibvrr.uploadImagem.MainActivityStorage.java
@AfterPermissionGranted(RC_STORAGE_PERMS) private void launchCamera() { Log.d(TAG, "launchCamera"); // Check that we have permission to read images from external storage. String perm = Manifest.permission.WRITE_EXTERNAL_STORAGE; if (!EasyPermissions.hasPermissions(this, perm)) { EasyPermissions.requestPermissions(this, getString(R.string.rationale_storage), RC_STORAGE_PERMS, perm); return;//from ww w . ja v a 2s .c om } // Choose file storage location, must be listed in res/xml/file_paths.xml File dir = new File(Environment.getExternalStorageDirectory() + "/photos"); File file = new File(dir, UUID.randomUUID().toString() + ".jpg"); try { // Create directory if it does not exist. if (!dir.exists()) { dir.mkdir(); } boolean created = file.createNewFile(); Log.d(TAG, "file.createNewFile:" + file.getAbsolutePath() + ":" + created); } catch (IOException e) { Log.e(TAG, "file.createNewFile" + file.getAbsolutePath() + ":FAILED", e); } // Create content:// URI for file, required since Android N // See: https://developer.android.com/reference/android/support/v4/content/FileProvider.html mFileUri = FileProvider.getUriForFile(this, "com.google.firebase.quickstart.firebasestorage.fileprovider", file); // Create and launch the intent Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mFileUri); startActivityForResult(takePictureIntent, RC_TAKE_PICTURE); }
From source file:org.apache.cordova.camera.CameraLauncher.java
/** * Take a picture with the camera.//from w ww. ja va2s . c om * When an image is captured or the camera view is cancelled, the result is returned * in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult. * * The image can either be returned as a base64 string or a URI that points to the file. * To display base64 string in an img tag, set the source to: * img.src="data:image/jpeg;base64,"+result; * or to display URI in an img tag * img.src=result; * * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param returnType Set the type of image to return. */ public void takePicture(int returnType, int encodingType) { // Save the number of images currently on disk for later this.numPics = queryImgDB(whichContentStore()).getCount(); // Let's use the intent and see what happens Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Specify file so that large image is captured and returned File photo = createCaptureFile(encodingType); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); this.imageUri = Uri.fromFile(photo); if (this.cordova != null) { // Let's check to make sure the camera is actually installed. (Legacy Nexus 7 code) PackageManager mPm = this.cordova.getActivity().getPackageManager(); if (intent.resolveActivity(mPm) != null) { this.cordova.startActivityForResult((CordovaPlugin) this, intent, (CAMERA + 1) * 16 + returnType + 1); } else { LOG.d(LOG_TAG, "Error: You don't have a default camera. Your device may not be CTS complaint."); } } // else // LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity"); }
From source file:com.nicefontaine.seanachie.ui.imagestory.ImageStoryFragment.java
private void photo() { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) { try {/*from w w w .j av a 2 s . c om*/ File photoFile = FileUtils.createImageFile(); cacheImagePath(photoFile.getAbsolutePath()); Uri photoURI = FileProvider.getUriForFile(getActivity(), REPOSITORY, photoFile); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); getActivity().startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE); } catch (IOException e) { Timber.e(e); } } }
From source file:org.egov.android.view.activity.EditProfileActivity.java
/** * Function called when choosing the camera option. Start the implicit intent * ACTION_IMAGE_CAPTURE for result./*from ww w . ja v a 2 s. c o m*/ */ private void _openCamera() { Intent mediaCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); mediaCamera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(profileImage)); startActivityForResult(mediaCamera, CAPTURE_IMAGE); }
From source file:foam.starwisp.StarwispBuilder.java
public static void photo(StarwispActivity ctx, String path, int code) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Ensure that there's a camera activity to handle the intent if (takePictureIntent.resolveActivity(ctx.getPackageManager()) != null) { // Create the File where the photo should go File photoFile = null;// w w w .ja v a 2 s . c om photoFile = new File(path); // Continue only if the File was successfully created if (photoFile != null) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); ctx.startActivityForResult(takePictureIntent, code); } else { Log.i("starwisp", "Could not open photo file"); } } }
From source file:io.mapsquare.osmcontributor.ui.activities.PhotoActivity.java
private void takePicture() { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { try {/*from www . j a va 2 s . co m*/ photoFile = createImageFile(); } catch (IOException ex) { ex.printStackTrace(); } // Continue only if the File was successfully created if (photoFile != null) { Uri photoURI = FileProvider.getUriForFile(this, "io.mapsquare.osmcontributor.fileprovider", photoFile); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); startActivityForResult(takePictureIntent, REQUEST_CAMERA); } } }
From source file:com.remobile.camera.CameraLauncher.java
/** * Take a picture with the camera./*from w w w . j ava2s . c o m*/ * When an image is captured or the camera view is cancelled, the result is returned * in CordovaActivity.onActivityResult, which forwards the result to this.onActivityResult. * <p/> * The image can either be returned as a base64 string or a URI that points to the file. * To display base64 string in an img tag, set the source to: * img.src="data:image/jpeg;base64,"+result; * or to display URI in an img tag * img.src=result; * * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param returnType Set the type of image to return. */ public void takePicture(int returnType, int encodingType) { // Save the number of images currently on disk for later this.numPics = queryImgDB(whichContentStore()).getCount(); // Let's use the intent and see what happens Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // Specify file so that large image is captured and returned File photo = createCaptureFile(encodingType); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); this.imageUri = Uri.fromFile(photo); if (this.cordova != null) { // Let's check to make sure the camera is actually installed. (Legacy Nexus 7 code) PackageManager mPm = this.cordova.getActivity().getPackageManager(); if (intent.resolveActivity(mPm) != null) { this.cordova.startActivityForResult((CordovaPlugin) this, intent, (CAMERA + 1) * 16 + returnType + 1); } else { FLog.d(LOG_TAG, "Error: You don't have a default camera. Your device may not be CTS complaint."); } } // else // FLog.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity"); }