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

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

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)

有没有人有任何关于这个问题的经验,或有解决方案的想法?


我会远离您使用的Intent,因为它不是标准的,所以可能无处不在,

从您使用的额外数据中,我相信您正在做一个固定大小的裁剪,并且不需要任何用户输入。 这使得解决方案非常简单,只要你没有耗尽内存。

  • 通过BitmapFactory.decodeFile加载图像。 您可以传入一个BitmapFactory.options对象以在加载时可选地缩放图像。
  • 使用Bitmap.createBitmap创建裁剪位图(位图源,int x,int y,int width,int height)
  • 用Bitmap.compress将其写入磁盘
  • 链接地址: http://www.djcxy.com/p/6257.html

    上一篇: com.android.camera.action.CROP sets wallpaper on Motorola Defy

    下一篇: Java FXML TableColumn not supporting GregorianCalendar