Java com.android.camera.action.CROP在摩托罗拉Defy上设置壁纸

Java com.android.camera.action.CROP在摩托罗拉Defy上设置壁纸,java,android,image-processing,android-intent,Java,Android,Image Processing,Android Intent,我正在开发一款Android 2.1+应用程序,试图拍摄一张照片,然后将拍摄结果发送给裁剪功能。它似乎在索尼爱立信xmp上工作,但当我将其放在Moto Defy上时,裁剪功能失败,因为它似乎忽略了我为数据输入的文件名,而是出于某种原因查看/data/data/com.motorola.gallery/files/temp wallpar。这是因为裁剪功能没有返回任何数据,而我刚才拍摄的图像被设置为手机的壁纸图像! 下面是一些示例代码: public static final String SD_

我正在开发一款Android 2.1+应用程序,试图拍摄一张照片,然后将拍摄结果发送给裁剪功能。它似乎在索尼爱立信xmp上工作,但当我将其放在Moto Defy上时,裁剪功能失败,因为它似乎忽略了我为数据输入的文件名,而是出于某种原因查看
/data/data/com.motorola.gallery/files/temp wallpar
。这是因为裁剪功能没有返回任何数据,而我刚才拍摄的图像被设置为手机的壁纸图像! 下面是一些示例代码:

public static final String SD_CARD_TEMP_DIR = Environment.getExternalStorageDirectory() + File.separator;
public static final String SD_CARD_TEMP_ORIG = SD_CARD_TEMP_DIR + "origPhoto.jpg";
public static final String SD_CARD_TEMP_CROP = SD_CARD_TEMP_DIR + "croppedPhoto.jpg";

Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(Uri.fromFile(new File(Const.SD_CARD_TEMP_ORIG)), "image/*");
intent.putExtra("crop", true);
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 512);
intent.putExtra("outputY", 512);
intent.putExtra("return-data", false);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(new File(Const.SD_CARD_TEMP_CROP)));
此操作的输出如下所示:

INFO/ActivityManager(1242): Starting activity: Intent { act=com.android.camera.action.CROP dat=file:///sdcard/origPhoto.jpg typ=image/* cmp=com.motorola.gallery/.CropImage (has extras) }
INFO/ActivityManager(1242): Start proc com.motorola.gallery:CropImage for activity com.motorola.gallery/.CropImage: pid=25733 uid=10014 gids={1015, 9003, 9007, 9008, 2001, 3003}
WARN/CropImage(25733): CropImg mBitmap was null, retreive frm URIfile:///sdcard/origPhoto.jpg
ERROR/CropImage(25733): got IOException java.io.FileNotFoundException: /data/data/com.motorola.gallery/files/temp-wallpaper 
INFO/ActivityManager(1242): Displayed activity com.motorola.gallery/.CropImage: 5664 ms (total 5664 ms)
WARN/System.err(25672): java.io.FileNotFoundException: /sdcard/croppedPhoto.jpg
DEBUG/(25672): unable to unlink '/sdcard/croppedPhoto.jpg': No such file or directory (errno=2)

有没有人对这个问题有任何经验,或者有什么想法可以解决这个问题?

我不同意您使用的意图,因为它不是标准的,所以可能不会在任何地方都得到支持

从您使用的额外数据来看,我相信您正在进行固定大小的裁剪,不需要任何用户输入。这使得解决方案非常简单,只要不耗尽内存

  • 通过加载图像。可以传入对象,以在加载时选择性地缩放图像
  • 使用创建裁剪的位图
  • 将其写入磁盘,并使用

  • @Elrond:android SDK中不包含
    com.android.camera.action.CROP
    Intent
    操作。不能保证它能在任何设备上工作。我在其他地方遇到过这一点,这就是为什么我想知道是否有其他解决方法?给自己写一个图像裁剪活动。或者,看看是否有人已经写了一个开源的。相关:这是一个固定大小的裁剪,但这并不意味着我不需要用户输入。用户被要求在图像的适当位置定位和/或调整裁剪区域的大小。值得一提的是,我最终使用了上面列出的解决方案,这是一种享受@Elroid该链接已损坏,但仍然可以通过Wayback机器使用:哪些链接指向此github回购: