Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- File pics = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
- File cameraPhotoFile = new File(pics, System.currentTimeMillis()+".jpg");
- if (takePicture.resolveActivity(getActivity().getPackageManager()) != null) {
- takePicture.putExtra(MediaStore.EXTRA_OUTPUT, cameraPhotoFile);
- startActivityForResult(takePicture, REQUEST_CAMERA);
- }
- if (resultCode == RESULT_OK && requestCode ==REQUEST_CAMERA) {
- uri = data.getData();
- performCrop();
- private void performCrop() {
- // take care of exceptions
- try {
- // call the standard crop action intent (the user device may not
- // support it)
- Intent cropIntent = new Intent("com.android.camera.action.CROP");
- // indicate image type and Uri
- cropIntent.setDataAndType(uri, "image/*");
- // set crop properties
- cropIntent.putExtra("crop", "true");
- // indicate aspect of desired crop
- cropIntent.putExtra("aspectX", 1);
- cropIntent.putExtra("aspectY", 1);
- // indicate output X and Y
- cropIntent.putExtra("outputX", 128);
- cropIntent.putExtra("outputY", 128);
- cropIntent.putExtra("scale", true);
- // retrieve data on return
- cropIntent.putExtra("return-data", true);
- // start the activity - we handle returning in onActivityResult
- startActivityForResult(cropIntent, CROP_PIC);
- }
- else if (requestCode == CROP_PIC) {
- // try{
- Bundle extras = data.getExtras();
- // get the cropped bitmap
- if (extras != null) {
Add Comment
Please, Sign In to add comment