Android-App for Android application blocks on some phones (about 20% of them)

I've researched this problem and saw some wonderful answers and find good resources to solve this problem. Unfortunately, however, I still encounter a lot of application crashes on some devices. Accidents happen after someone took your picture, and the camera purpose is to transmit the information back to the calling activity. For the purposes of my application I just rewrite any existing photo with a recent photo, so I can use quite a static path to the file location. That is what I call the intention of:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // get the file path from an external class (necessary for galaxy nexus) imageFileAndPath = ImageServices.getOutputImageFileUri(cont); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageFileAndPath); startActivityForResult(intent, CAMERA_REQUEST_CODE); 

imageFileAndPath - it's just a URI variable, and I have made it from a separate class because it allowed another issue in which clicking "done" or a check mark or w / e on a specific device to close the intention of the camera was not doing anything on multiple device types . Creating a URI from a particular class, it solves this problem for some unknown reason.

my onActivityResult looks like this:

 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(resultCode == Activity.RESULT_OK) { if (requestCode == CAMERA_REQUEST_CODE) { setupImageView(); imageView = (ImageView) findViewById(R.id.image_view); webView.setVisibility(View.GONE); imageView.setVisibility(View.VISIBLE); button.setVisibility(View.GONE); reTakePicButton.setVisibility(View.VISIBLE); rl.setVisibility(View.VISIBLE); } } } ); @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if(resultCode == Activity.RESULT_OK) { if (requestCode == CAMERA_REQUEST_CODE) { setupImageView(); imageView = (ImageView) findViewById(R.id.image_view); webView.setVisibility(View.GONE); imageView.setVisibility(View.VISIBLE); button.setVisibility(View.GONE); reTakePicButton.setVisibility(View.VISIBLE); rl.setVisibility(View.VISIBLE); } } } 

because I do not need a dynamic path to save my pictures (because it overwrites the existing pictures), I'm just calling another method in the activity that changes the size of the photo and, accordingly, it turns. This method is as follows:

 private void setupImageView() { imageLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myappphoto/myappphoto.jpg"; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); int rotationForImage = getRotationForImage(imageLocation); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; } Bitmap resized; if(bitmap.getWidth() >= 900 || bitmap.getHeight() >=900) { int newWidth = Math.round(bitmap.getWidth()/2); int newHeight = Math.round(bitmap.getHeight()/2); resized = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); } else { resized = bitmap; } //bitmap.recycle(); bitmap = resized; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} imageView.setImageBitmap(bitmap); } ) + "/myappphoto/myappphoto.jpg"; private void setupImageView() { imageLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myappphoto/myappphoto.jpg"; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); int rotationForImage = getRotationForImage(imageLocation); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; } Bitmap resized; if(bitmap.getWidth() >= 900 || bitmap.getHeight() >=900) { int newWidth = Math.round(bitmap.getWidth()/2); int newHeight = Math.round(bitmap.getHeight()/2); resized = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); } else { resized = bitmap; } //bitmap.recycle(); bitmap = resized; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} imageView.setImageBitmap(bitmap); } image private void setupImageView() { imageLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myappphoto/myappphoto.jpg"; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); int rotationForImage = getRotationForImage(imageLocation); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; } Bitmap resized; if(bitmap.getWidth() >= 900 || bitmap.getHeight() >=900) { int newWidth = Math.round(bitmap.getWidth()/2); int newHeight = Math.round(bitmap.getHeight()/2); resized = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); } else { resized = bitmap; } //bitmap.recycle(); bitmap = resized; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} imageView.setImageBitmap(bitmap); } , photoH / targetW); private void setupImageView() { imageLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myappphoto/myappphoto.jpg"; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); int rotationForImage = getRotationForImage(imageLocation); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; } Bitmap resized; if(bitmap.getWidth() >= 900 || bitmap.getHeight() >=900) { int newWidth = Math.round(bitmap.getWidth()/2); int newHeight = Math.round(bitmap.getHeight()/2); resized = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); } else { resized = bitmap; } //bitmap.recycle(); bitmap = resized; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} imageView.setImageBitmap(bitmap); } sized to fill the View private void setupImageView() { imageLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myappphoto/myappphoto.jpg"; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); int rotationForImage = getRotationForImage(imageLocation); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; } Bitmap resized; if(bitmap.getWidth() >= 900 || bitmap.getHeight() >=900) { int newWidth = Math.round(bitmap.getWidth()/2); int newHeight = Math.round(bitmap.getHeight()/2); resized = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); } else { resized = bitmap; } //bitmap.recycle(); bitmap = resized; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} imageView.setImageBitmap(bitmap); } ); private void setupImageView() { imageLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myappphoto/myappphoto.jpg"; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); int rotationForImage = getRotationForImage(imageLocation); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; } Bitmap resized; if(bitmap.getWidth() >= 900 || bitmap.getHeight() >=900) { int newWidth = Math.round(bitmap.getWidth()/2); int newHeight = Math.round(bitmap.getHeight()/2); resized = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); } else { resized = bitmap; } //bitmap.recycle(); bitmap = resized; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} imageView.setImageBitmap(bitmap); } , bitmap.getConfig ()); private void setupImageView() { imageLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myappphoto/myappphoto.jpg"; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); int rotationForImage = getRotationForImage(imageLocation); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; } Bitmap resized; if(bitmap.getWidth() >= 900 || bitmap.getHeight() >=900) { int newWidth = Math.round(bitmap.getWidth()/2); int newHeight = Math.round(bitmap.getHeight()/2); resized = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); } else { resized = bitmap; } //bitmap.recycle(); bitmap = resized; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} imageView.setImageBitmap(bitmap); } ; private void setupImageView() { imageLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myappphoto/myappphoto.jpg"; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); int rotationForImage = getRotationForImage(imageLocation); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; } Bitmap resized; if(bitmap.getWidth() >= 900 || bitmap.getHeight() >=900) { int newWidth = Math.round(bitmap.getWidth()/2); int newHeight = Math.round(bitmap.getHeight()/2); resized = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); } else { resized = bitmap; } //bitmap.recycle(); bitmap = resized; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} imageView.setImageBitmap(bitmap); } ()); private void setupImageView() { imageLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myappphoto/myappphoto.jpg"; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); int rotationForImage = getRotationForImage(imageLocation); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; } Bitmap resized; if(bitmap.getWidth() >= 900 || bitmap.getHeight() >=900) { int newWidth = Math.round(bitmap.getWidth()/2); int newHeight = Math.round(bitmap.getHeight()/2); resized = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); } else { resized = bitmap; } //bitmap.recycle(); bitmap = resized; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} imageView.setImageBitmap(bitmap); } / private void setupImageView() { imageLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myappphoto/myappphoto.jpg"; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); int rotationForImage = getRotationForImage(imageLocation); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; } Bitmap resized; if(bitmap.getWidth() >= 900 || bitmap.getHeight() >=900) { int newWidth = Math.round(bitmap.getWidth()/2); int newHeight = Math.round(bitmap.getHeight()/2); resized = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); } else { resized = bitmap; } //bitmap.recycle(); bitmap = resized; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} imageView.setImageBitmap(bitmap); } / private void setupImageView() { imageLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myappphoto/myappphoto.jpg"; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); int rotationForImage = getRotationForImage(imageLocation); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; } Bitmap resized; if(bitmap.getWidth() >= 900 || bitmap.getHeight() >=900) { int newWidth = Math.round(bitmap.getWidth()/2); int newHeight = Math.round(bitmap.getHeight()/2); resized = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); } else { resized = bitmap; } //bitmap.recycle(); bitmap = resized; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} imageView.setImageBitmap(bitmap); } newHeight, true); private void setupImageView() { imageLocation = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myappphoto/myappphoto.jpg"; // Get the dimensions of the View Display display = getWindowManager().getDefaultDisplay(); Point size = getDisplaySize(display); int targetW = size.x; // Get the dimensions of the bitmap BitmapFactory.Options bmOptions = new BitmapFactory.Options(); bmOptions.inJustDecodeBounds = true; BitmapFactory.decodeFile(imageLocation, bmOptions); int photoW = bmOptions.outWidth; int photoH = bmOptions.outHeight; // Determine how much to scale down the image int scaleFactor = Math.min(photoW / targetW, photoH / targetW); // Decode the image file into a Bitmap sized to fill the View bmOptions.inJustDecodeBounds = false; bmOptions.inSampleSize = scaleFactor; bmOptions.inPurgeable = true; Bitmap bitmap = BitmapFactory.decodeFile(imageLocation, bmOptions); int rotationForImage = getRotationForImage(imageLocation); if (rotationForImage != 0) { int targetWidth = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getHeight() : bitmap.getWidth(); int targetHeight = rotationForImage == 90 || rotationForImage == 270 ? bitmap.getWidth() : bitmap.getHeight(); Bitmap rotatedBitmap = Bitmap.createBitmap(targetWidth, targetHeight, bitmap.getConfig()); Canvas canvas = new Canvas(rotatedBitmap); Matrix matrix = new Matrix(); matrix.setRotate(rotationForImage, bitmap.getWidth() / 2, bitmap.getHeight() / 2); canvas.drawBitmap(bitmap, matrix, new Paint()); bitmap.recycle(); bitmap = rotatedBitmap; } Bitmap resized; if(bitmap.getWidth() >= 900 || bitmap.getHeight() >=900) { int newWidth = Math.round(bitmap.getWidth()/2); int newHeight = Math.round(bitmap.getHeight()/2); resized = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); } else { resized = bitmap; } //bitmap.recycle(); bitmap = resized; ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 70, bytes); try { File f = new File(imageLocation); f.createNewFile(); //write the bytes in file FileOutputStream fo = new FileOutputStream(f); fo.write(bytes.toByteArray()); fo.close(); } catch(java.io.IOException e){} imageView.setImageBitmap(bitmap); } 

you can see the static path in the upper part of the method of the image file stored in the camera to do this.

I believe that the way to change the size and rotation causes failures, but I do not understand why it would be that it looks like a standard java-encoding for me.

Can anyone see something very bad that I'm doing here? As I said in the title of this thread is my code crashes by about 20% of the devices that run it, that is unacceptable. I can handle the 5%, but not 20%.

I understand that the Android development in this regard is a nightmare, because you have to consider many different types of devices (manufacturers, Android version, etc.), but I think the camera is activated it should be better standardized than this. As I said at the top of this topic, I did a lot of studying this problem and saw several people with similar problems to mine, but does not have good resolution, which covers most of the devices. I really do not want to write (and do not think I'll have to write) his own camera from scratch. To be the best implementation of a standard built into the camera at the intention Android devices. I just couldn't find him yet. As you can see, I'm not even interested in the dynamic creation of images, which should make this project more subtle.

TIA

Edit: In the comments below, I've added a stop-loss of a faulty camera. This is similar to an exception with a null pointer. I took 6 shots and kept coming back with the button that calls the camera intent, until finally, it does not, that she had failed. Here's the stack trace:

 STACK_TRACE "java.lang.RuntimeException: Unable to resume activity {com.myapp/com.myapp.MyActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2124) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) ... 13 more Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) com.myapp / com.myapp.MyActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo {who = null, request = STACK_TRACE "java.lang.RuntimeException: Unable to resume activity {com.myapp/com.myapp.MyActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2124) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) ... 13 more Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) : java.lang.NullPointerException STACK_TRACE "java.lang.RuntimeException: Unable to resume activity {com.myapp/com.myapp.MyActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2124) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) ... 13 more Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) ResultInfo {who = null, request = STACK_TRACE "java.lang.RuntimeException: Unable to resume activity {com.myapp/com.myapp.MyActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2124) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) ... 13 more Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) } to activity {com.myapp / com.myapp.MyActivity}: java.lang.NullPointerException STACK_TRACE "java.lang.RuntimeException: Unable to resume activity {com.myapp/com.myapp.MyActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2124) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) ... 13 more Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) = null, request = STACK_TRACE "java.lang.RuntimeException: Unable to resume activity {com.myapp/com.myapp.MyActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2124) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) ... 13 more Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) } to activity {com.myapp / com.myapp.MyActivity}: java.lang.NullPointerException STACK_TRACE "java.lang.RuntimeException: Unable to resume activity {com.myapp/com.myapp.MyActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2124) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) ... 13 more Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=904, result=-1, data=null} to activity {com.myapp/com.myapp.MyActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2536) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) ... 14 more java.lang.NullPointerException at com.myapp.MyActivity.onActivityResult(EnterContest.java:257) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2532) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2111) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2139) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1672) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2836) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3687) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600) at dalvik.system.NativeStart.main(Native Method) 
+4
source share
3 answers

Perhaps the assumption, but I think I had the same problem, I corrected it by reading the bitmap in a new AsyncTask, instead of on the UI thread.

An exception occurred (apparently randomly) by calling

 getContentResolver().notifyChange(selectedImage, null); 

where selectedImage - this URI, previously set in

 intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo)); 

You called in com.myapp.MyActivity.onActivityResult (EnterContest.java:257)?

I have a stack trace compiled using ACRA:

 java.lang.RuntimeException: Unable to resume activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2126) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) ... 13 more Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) }: java.lang.RuntimeException: Failure delivering result ResultInfo {who = null, request = java.lang.RuntimeException: Unable to resume activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2126) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) ... 13 more Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) {dat = content: // media / external / images / media / java.lang.RuntimeException: Unable to resume activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2126) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) ... 13 more Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) ResultInfo {who = null, request = java.lang.RuntimeException: Unable to resume activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2126) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) ... 13 more Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) {dat = content: // media / external / images / media / java.lang.RuntimeException: Unable to resume activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2126) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) ... 13 more Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) ) java.lang.RuntimeException: Unable to resume activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2126) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) ... 13 more Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) ) java.lang.RuntimeException: Unable to resume activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2126) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) ... 13 more Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) ) java.lang.RuntimeException: Unable to resume activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2126) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) ... 13 more Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=7898789, result=-1, data=Intent { dat=content://media/external/images/media/9 }} to activity {com.infonair.meetme.app/com.infonair.meetme.activity.photo.TakePhotoActivity}: java.lang.NullPointerException at android.app.ActivityThread.deliverResults(ActivityThread.java:2538) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) ... 14 more java.lang.NullPointerException at android.os.Parcel.readException(Parcel.java:1328) at android.os.Parcel.readException(Parcel.java:1276) at android.content.IContentService$Stub$Proxy.notifyChange(IContentService.java:458) at android.content.ContentResolver.notifyChange(ContentResolver.java:912) at android.content.ContentResolver.notifyChange(ContentResolver.java:898) at com.infonair.meetme.activity.photo.TakePhotoActivity.onActivityResult(TakePhotoActivity.java:154) at android.app.Activity.dispatchActivityResult(Activity.java:3908) at android.app.ActivityThread.deliverResults(ActivityThread.java:2534) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2113) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2141) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1674) at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2838) at android.app.ActivityThread.access$1600(ActivityThread.java:117) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:130) at android.app.ActivityThread.main(ActivityThread.java:3737) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:894) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652) at dalvik.system.NativeStart.main(Native Method) 
+2
source

Struggling with this problem, I noticed that on some devices, the captured image was too big even for the display in the ImageView (there was a warning that the image is too wide for the texture), so I started working on changing its size on the server. usable size.

I will post all the code (at least the one that comes to photography and image manipulation), just in case

Here is the code to call the intent

  public void takePhoto() { String directoryPath = DCIM_PATH; this.pictureFileName = Long.toHexString(System.currentTimeMillis())+".jpg"; String filePath = directoryPath + pictureFileName ; File directory = new File(directoryPath); if (!directory.exists()) { directory.mkdirs(); } this.imageUri = Uri.parse(filePath); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra( MediaStore.EXTRA_OUTPUT,Uri.fromFile( new File(filePath) ) ); startActivityForResult(intent, TAKE_PICTURE); } + "jpg.";  public void takePhoto() { String directoryPath = DCIM_PATH; this.pictureFileName = Long.toHexString(System.currentTimeMillis())+".jpg"; String filePath = directoryPath + pictureFileName ; File directory = new File(directoryPath); if (!directory.exists()) { directory.mkdirs(); } this.imageUri = Uri.parse(filePath); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra( MediaStore.EXTRA_OUTPUT,Uri.fromFile( new File(filePath) ) ); startActivityForResult(intent, TAKE_PICTURE); } ;  public void takePhoto() { String directoryPath = DCIM_PATH; this.pictureFileName = Long.toHexString(System.currentTimeMillis())+".jpg"; String filePath = directoryPath + pictureFileName ; File directory = new File(directoryPath); if (!directory.exists()) { directory.mkdirs(); } this.imageUri = Uri.parse(filePath); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra( MediaStore.EXTRA_OUTPUT,Uri.fromFile( new File(filePath) ) ); startActivityForResult(intent, TAKE_PICTURE); } ;  public void takePhoto() { String directoryPath = DCIM_PATH; this.pictureFileName = Long.toHexString(System.currentTimeMillis())+".jpg"; String filePath = directoryPath + pictureFileName ; File directory = new File(directoryPath); if (!directory.exists()) { directory.mkdirs(); } this.imageUri = Uri.parse(filePath); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra( MediaStore.EXTRA_OUTPUT,Uri.fromFile( new File(filePath) ) ); startActivityForResult(intent, TAKE_PICTURE); } ))  public void takePhoto() { String directoryPath = DCIM_PATH; this.pictureFileName = Long.toHexString(System.currentTimeMillis())+".jpg"; String filePath = directoryPath + pictureFileName ; File directory = new File(directoryPath); if (!directory.exists()) { directory.mkdirs(); } this.imageUri = Uri.parse(filePath); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra( MediaStore.EXTRA_OUTPUT,Uri.fromFile( new File(filePath) ) ); startActivityForResult(intent, TAKE_PICTURE); } 

in onActivityResult I call the method to work with the newly made image

  @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case TAKE_PICTURE: if (resultCode == Activity.RESULT_OK) { loadImageJustTaken(imageUri); } break; } } 

That said the method

 public void loadImageJustTaken(Uri selectedImage) { mActivity.getApplicationContext().getContentResolver().notifyChange(selectedImage, null); /* * process image to make its wide equals IMG_WIDTH constant, so that larger images will fit in ImageView */ Bitmap b = BitmapHelper.decodeFileToScaledBitmap(new File(imageUri.getPath()), Tapabook.IMG_WIDTH); ivPicture.setImageBitmap(b); ivPicture.setVisibility(View.VISIBLE); System.gc(); } notifyChange (selectedImage, null); public void loadImageJustTaken(Uri selectedImage) { mActivity.getApplicationContext().getContentResolver().notifyChange(selectedImage, null); /* * process image to make its wide equals IMG_WIDTH constant, so that larger images will fit in ImageView */ Bitmap b = BitmapHelper.decodeFileToScaledBitmap(new File(imageUri.getPath()), Tapabook.IMG_WIDTH); ivPicture.setImageBitmap(b); ivPicture.setVisibility(View.VISIBLE); System.gc(); } IMG_WIDTH constant, so that larger images will fit in ImageView public void loadImageJustTaken(Uri selectedImage) { mActivity.getApplicationContext().getContentResolver().notifyChange(selectedImage, null); /* * process image to make its wide equals IMG_WIDTH constant, so that larger images will fit in ImageView */ Bitmap b = BitmapHelper.decodeFileToScaledBitmap(new File(imageUri.getPath()), Tapabook.IMG_WIDTH); ivPicture.setImageBitmap(b); ivPicture.setVisibility(View.VISIBLE); System.gc(); } imageUri.getPath ()), Tapabook.IMG_WIDTH); public void loadImageJustTaken(Uri selectedImage) { mActivity.getApplicationContext().getContentResolver().notifyChange(selectedImage, null); /* * process image to make its wide equals IMG_WIDTH constant, so that larger images will fit in ImageView */ Bitmap b = BitmapHelper.decodeFileToScaledBitmap(new File(imageUri.getPath()), Tapabook.IMG_WIDTH); ivPicture.setImageBitmap(b); ivPicture.setVisibility(View.VISIBLE); System.gc(); } 

And here's the code for my class BitmapHelper

 public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } "; public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } int WIDTH) throws IOException { public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } ); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } to jpg"); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } temp.jpg"); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } "); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } ; public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } "); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } "); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } int WIDTH) { public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } null, o); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } to public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } : [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT + "]"); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } / REQUIRED_WIDTH); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } " + e.getMessage ()); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } int WIDTH) { public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } : [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT + "]"); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } / REQUIRED_WIDTH); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } bitmap"); public class BitmapHelper { private static final String LOGTAG = "BitmapHelper"; public static File scaleBitmapFile(File f, int WIDTH) throws IOException{ Log.d(LOGTAG, "scaleBitmapFile to WIDTH: " + WIDTH); Bitmap b2 = decodeFileToScaledBitmap( f, WIDTH); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); Log.d(LOGTAG, "scaleBitmapFile compress bitmap to jpg "); b2.compress(Bitmap.CompressFormat.JPEG,70 , outStream); File scaledBitmapFile = new File(Environment.getExternalStorageDirectory() + File.separator + "temp.jpg"); Log.d(LOGTAG, "scaleBitmapFile file: temp.jpg" ); scaledBitmapFile.createNewFile(); Log.d(LOGTAG, "scaleBitmapFile file CREATED" ); //write the bytes in file FileOutputStream fo = new FileOutputStream(scaledBitmapFile); fo.write(outStream.toByteArray()); Log.d(LOGTAG, "scaleBitmapFile file WRITTEN" ); // remember close de FileOutput fo.close(); Log.d(LOGTAG, "scaleBitmapFile file CLOSED" ); return scaledBitmapFile; } public static Bitmap decodeFileToScaledBitmap(File f, int WIDTH){ Log.d(LOGTAG, "decodeFileToScaledBitmap to WIDTH: " + WIDTH); try{ //Decode image size BitmapFactory.Options o = new BitmapFactory.Options(); o.inJustDecodeBounds = true; BitmapFactory.decodeStream(new FileInputStream(f),null,o); //The new size we want to scale to final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = o.outWidth; final int ORIG_HEIGHT = o.outHeight; Log.d(LOGTAG, "decodeFileToScaledBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; //Decode with scaled height Log.d(LOGTAG, "decodeFileToScaledBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( BitmapFactory.decodeFile(f.getAbsolutePath()), REQUIRED_WIDTH, REQUIRED_HEIGHT, false); }catch (FileNotFoundException e) { Log.e(LOGTAG, "decodeFileToScaledBitmap FileNotFoundException: " +e.getMessage()); } return null; } public static Bitmap scaleBitmap(Bitmap b, int WIDTH){ final int REQUIRED_WIDTH=WIDTH; final int ORIG_WIDTH = b.getWidth(); final int ORIG_HEIGHT = b.getHeight(); Log.d(LOGTAG, "scaleBitmap original width: [" + ORIG_WIDTH + "] original height: [" + ORIG_HEIGHT+ "]"); final int REQUIRED_HEIGHT = ORIG_HEIGHT/( ORIG_WIDTH / REQUIRED_WIDTH ) ; Log.d(LOGTAG, "scaleBitmap returning scaled bitmap "); return Bitmap.createScaledBitmap( b, REQUIRED_WIDTH, REQUIRED_HEIGHT, false); } } 

With it, I no longer have problems when taking on Samsung devices, older handhelds such as SG3 / Apollo, or the newer plates, such as SGTab 10.1. I hope this helps :)

0
source

See this post here Uri Content knocks the camera on Android KitKat

Some older applications do not support the camera properly URI content: // and fly at EXTRA_OUTPUT transmission that is not a file: // URI. I noticed this error when updating my code to support FileProviders in Android N +. If you change the URI to a file: // URI for applications with less SDK Android N, you'll be able to solve this problem.

0
source

All Articles