4

I'm running into an issue with my program when trying to crop an image selected by the user from their gallery. The issue so far only appears when running on a Droid X, as running on the original moto Droid works fine.

Basically the issue occurs as the cropping intent is being run. Once the user crops the photo and clicks the save button, it replaces the wallpaper on the main screen with the cropped image that was saved! It does not do this on the moto droid, or emulators. Below is the code for cropping and saving the picture to the SD card:

@Override
public void onActivityResult(int requestCode,int resultCode,Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode ==1){
if (resultCode == Activity.RESULT_OK) {
  Intent i = new Intent("com.android.camera.action.CROP");
  i.setData(data.getData());
  i.putExtra("noFaceDetection", true);
  i.putExtra("outputX", 80);
  i.putExtra("outputY", 80);
  i.putExtra("aspectX", 1);
  i.putExtra("aspectY", 1);
  i.putExtra("scale", true);


if(selectedImageString == null){
      ContentValues values = new ContentValues();
      values.put(android.provider.MediaStore.Images.Media.TITLE, "Temp_Icon1");
      values.put(android.provider.MediaStore.Images.Media.BUCKET_ID, "Temp_Icons");
      values.put(android.provider.MediaStore.Images.Media.BUCKET_DISPLAY_NAME,"Temp_Icons");
      values.put(android.provider.MediaStore.Images.Media.IS_PRIVATE, 1);
      selectedImageString = getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values).toString();
  }
  i.putExtra("output", Uri.parse(selectedImageString));
  startActivityForResult(i, 2);
}
}
 if(requestCode == 2){
 if (resultCode == Activity.RESULT_OK){
  uriPath = Uri.parse(selectedImageString);
  imageView.setImageURI(uriPath);
 }
}

}

Can someone please help me with this?

blahdiblah
  • 33,069
  • 21
  • 98
  • 152
Brian
  • 135
  • 9
  • I'm seeing the same issue in my application on Droid 2. Any ideas? I noticed the contacts application on Droid 2 does not have the same side effect of updating the wallpaper after cropping so there must be a way to avoid this in our apps... – manisha Jan 07 '11 at 23:07
  • Related: [Problem with com.android.camera.action.CROP on Motorola Defy](http://stackoverflow.com/q/5709601) – blahdiblah Mar 05 '13 at 03:31

3 Answers3

3

I can verify that the Droid X is doing the same for me even with the "output" option mentioned above. I have found no way around it as of yet and will look at blocking the crop feature for Droid X phones as well. It is ashame it doesn't work here.

By they way, you could try the following...

i.putExtra("return-data", true);

This returns the image in the returned intent. You can access it with the following...

BitMap BM = data.getParcelableExtra("data");

This, however, is not supported by the Galaxy S line of phones. It returns an empty parcel no matter what. So, I have found no good solution yet.

Philip
  • 46
  • 1
1

It could be that since you don't specify where to put the data when calling the crop intent that it is overwriting the image.

The crop intent is internal code I think so I'm not sure we can know for sure (the crop intent isn't found on all phones either btw)

When I call the crop intent I pass

i.putExtra("output", croppedOutputUri);
dweebo
  • 3,222
  • 1
  • 17
  • 19
  • Thanks, I decided to limit the cropping ability to just the phones I can physically test and confirm working the way I need it to. – Brian Sep 22 '10 at 17:09
  • @losSebos suggests that MediaStore.EXTRA_OUTPUT would be better than "output". – Jonathan Mar 14 '13 at 10:46
0

Have you tried placing:

i.putExtra("setWallpaper", false);

I took it from here: https://github.com/lvillani/android-cropimage/blob/master/src/com/android/camera/CropImage.java

theres a library whihc was probably takien from original sources and modified and you can see this attribute set there

voytez
  • 1,814
  • 16
  • 16