Good day.
Such a problem: the user can not add the image to the application from the gallery in JPEG format. On a computer with an emulator, everything is in order. But an error comes out on the smartphone. I wanted to try to connect via USB, but I can not update the driver> <
This is how the image is processed:

try { imageTarget.setImageBitmap(null); final Uri imageUri = imageReturnedIntent.getData(); final InputStream imageStream = getActivity().getContentResolver().openInputStream(imageUri); selectedImage = BitmapFactory.decodeStream(imageStream); int h; int w; if (selectedImage.getHeight() > selectedImage.getWidth()) { h = selectedImage.getHeight() / (selectedImage.getWidth() / 400); w = 400; } else { h = 240; w = selectedImage.getWidth() / (selectedImage.getHeight() / 240); } imageTarget.setImageBitmap(Bitmap.createScaledBitmap(selectedImage, w , h , false)); addImageButton.setEnabled(false); addImageButton.setVisibility(View.INVISIBLE); editImageButton.setEnabled(true); editImageButton.setVisibility(View.VISIBLE); deleteImageButton.setEnabled(true); deleteImageButton.setVisibility(View.VISIBLE); } catch (FileNotFoundException e) { e.printStackTrace(); } 
  • one
    Those. You can not get the device logs? Try to connect it via wi-fi. And the error is probably due to the lack of a request for permission to the OS version more than 6 - YuriySPb

1 answer 1

I had something similar, I did not have enough memory to process, I got an error when adding an image (although everything was good for the emulsion). Try to increase the amount of memory allocated for the image, and then squeeze it.

Starting with Android 3.0, you can ask the system to allocate a little more memory by writing a request in the manifest:

 <application .... largerHeap = "true">