Cropping Picture on Droid X sets resulting image as wallpaper
Asked Answered
B

3

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?

Broadcaster answered 13/9, 2010 at 14:50 Comment(2)
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...Yearning
Related: Problem with com.android.camera.action.CROP on Motorola DefyFarthingale
S
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.

Shote answered 6/10, 2010 at 18:39 Comment(0)
K
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);
Kayleen answered 17/9, 2010 at 15:38 Comment(2)
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.Broadcaster
@losSebos suggests that MediaStore.EXTRA_OUTPUT would be better than "output".Hyperboloid
R
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

Raconteur answered 8/7, 2013 at 11:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.