【发布时间】:2011-02-14 05:10:33
【问题描述】:
我正在开发一个应用程序,其中从本机相机应用程序拍摄的图像。是要显示给用户的。 我做的代码是:
/* Intent */
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, TAKE_PICTURE);
/* Result */
onActivityResult(int requestCode, int resultCode,
Intent returnIntent) {
if(requestCode == TAKE_PICTURE) {
//picture from Camera
if (resultCode == Activity.RESULT_OK) {
if(returnIntent != null) {
try {
// Get the file path where the image is stored.
// This runs fine on all devices, except Samsung ones.
Uri selectedImage = returnIntent.getData();
if(selectedImage == null) {
if(returnIntent.getExtras() != null &&
returnIntent.getExtras().get(AppConstants.DATA) != null) {
// But, I get the image Bitmap here. Means the image is stored in disk.
Bitmap bmp = (Bitmap) returnIntent.getExtras().get(AppConstants.DATA);
}
}
} catch (Exception e) {
//
}
}
}
}
}
这里的问题是,上面的代码在我尝试过的所有设备(HTC、SE)上都可以正常工作,但在三星设备上却以某种方式失败了。 “Uri selectedImage = returnIntent.getData();”从不返回任何东西。由于我的整个应用程序都是基于这种文件路径存储逻辑构建的,因此我无法继续。 有没有解决的人。
【问题讨论】:
-
你找到解决办法了吗?
标签: android