com.android.camera.action.CROP上设置摩托罗拉Defy壁纸 [英] com.android.camera.action.CROP sets wallpaper on Motorola Defy

查看:316
本文介绍了com.android.camera.action.CROP上设置摩托罗拉Defy壁纸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作在Android 2.1及以上版本的应用程序,并试图拍照,然后将该意图的结果发送到裁切功能。看来索尼爱立信XMP工作,但是当我把它放在一个摩托Defy的,作物函数失败,因为它似乎忽略了文件名,我把对数据,而是着眼于 /数据/数据​​/ com.motorola.gallery /文件/ TEMP墙纸出于某种原因。这有裁切功能不与任何数据返回的结果,我只是把图像被设置为手机壁纸图片!
下面是一些示例code:

I'm working on an Android 2.1+ app and trying to take a photo and then send the results of that intent to a crop function. It seems to work on the Sony Ericsson xmp, but when i put it on a Moto Defy, the crop function fails because it is seemingly ignoring the file name i put in for the data, and instead looks at /data/data/com.motorola.gallery/files/temp-wallpaper for some reason. This has the result of the crop function not returning with any data, and the image i just took gets set as the wallpaper image of the phone! Here's some sample code:

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)));

从这个输出是这样的:

The output from this is something like this:

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)

有没有人有这个问题的工作的经验或想法左右?

Does anyone have any experience with this issue, or ideas for a work around?

推荐答案

我会留在你使用的意图了,因为它不是标准,所以可能不支持无处不在,

I'd stay away from the Intent you're using, because it isn't standard, so may not be supported everywhere,

从你使用额外的数据,我相信你正在做一个固定大小的作物,并且不需要任何用户输入。这使得该解决方案很简单,只要你不内存用完。

From the extra-data you're using, I believe you're doing a fixed-size crop, and don't need any user input. This makes the solution quite simple, as long as you don't run out of memory.


  1. 加载通过<一个图像href=\"http://developer.android.com/reference/android/graphics/BitmapFactory.html#de$c$cFile%28java.lang.String,%20android.graphics.BitmapFactory.Options%29\"相对=nofollow> BitmapFactory.de codeFILE 。您可以在 BitmapFactory.options 对象可选择缩放在加载时的图像。

  2. 创建与<一个裁剪位图href=\"http://developer.android.com/reference/android/graphics/Bitmap.html#createBitmap%28android.graphics.Bitmap,%20int,%20int,%20int,%20int%29\"相对=nofollow> Bitmap.createBitmap(位图源,诠释的x,INT Y,INT宽度,高度INT)

  3. 写出来与<磁盘href=\"http://developer.android.com/reference/android/graphics/Bitmap.html#com$p$pss%28android.graphics.Bitmap.Com$p$pssFormat,%20int,%20java.io.OutputStream%29\"相对=nofollow> Bitmap.com preSS

  1. Load the image via BitmapFactory.decodeFile. You can pass in a BitmapFactory.options object to optionally scale the image at load time.
  2. Create a cropped bitmap with Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height)
  3. Write it out to disk with Bitmap.compress

这篇关于com.android.camera.action.CROP上设置摩托罗拉Defy壁纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆