I'm having troubles while trying to create a bitmap from a Camera AND an Image Picker.
I used a code that creates an Uri by the Camera so I added a condition to my function that already load pics from gallery. Here is the onActivityResult :
protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RESULT_LOAD_IMAGE || requestCode == RESULT_CAMERA) { Uri selectedImage = null; if(requestCode == RESULT_LOAD_IMAGE) { selectedImage = data.getData(); } else if(requestCode == RESULT_CAMERA) { selectedImage = imageUri; } if(resultCode == RESULT_OK && null != data) { String[] filePathColumn = {MediaStore.Images.Media.DATA}; imgViewScan.setImageURI(selectedImage); try { InputStream stream = getContentResolver().openInputStream( selectedImage); bitmapLoaded = BitmapFactory.decodeStream(stream); } catch (IOException e) { Log.e("ScanAc", e.toString()); } } } } and here is the onClick for the Camera :
View.OnClickListener takePicture = new View.OnClickListener() { public void onClick(View v) { String fileName = "new-photo-name.jpg"; //create parameters for Intent with filename ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, fileName); values.put(MediaStore.Images.Media.DESCRIPTION,"Image capture by camera"); //imageUri is the current activity attribute, define and save it for later usage (also in onSaveInstanceState) imageUri = getContentResolver().insert( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); //create new Intent Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); Intent i = new Intent( MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(i, RESULT_CAMERA); } }; I would like to precise that the gallery image pick works perfectly, the problem is only on the camera...