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(); }