In my app I am trying to set an ImageView‘s image to an image that was just taken with the camera. My problem is that it works on my old Droid (Android 2.2), but not on my Droid Razr (Android 4.0). I was wondering if anyone could help me figure out why.
Here is the camera Intent when the Take Photo button is clicked:
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
String imageFileName = System.currentTimeMillis() + ".jpg";
File photo = new File(Environment.getExternalStorageDirectory(),
imageFileName);
imageUri = Uri.fromFile(photo);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(cameraIntent, ACTIVITY_CAMERA);
Here is the Activity‘s result:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == ACTIVITY_CAMERA) {
if(resultCode == Activity.RESULT_OK){
imageView.setImageUri(imageUri);
}
}
}
The ImageView remains blank on the Razr.
Weird how looking at the logcat is helpful.
Anyway, I was getting “bitmap is too large” when trying to set the
ImageView‘s image. Even before this issue I tried Google’s solution here. However, the bitmap is always null and I haven’t looked into it enough to figure out why.EDIT: I got Google’s solution to work. For the
decodeFile()method, I was passing in myUrias a string:imageUri.toString(). I changed this toimageUri.getPath()and it is now working.