我正在开发一个应用程序,其中从本机相机应用程序拍摄的图像.将向用户显示.我做的代码是:
/* 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) {
//
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这里的问题是,上面的代码在我试过的所有设备(HTC,SE)上工作正常,但它在三星的某些方面失败了."Uri selectedImage = returnIntent.getData();" 永远不会退货.由于我的整个应用程序是基于文件路径存储的逻辑构建的,我无法继续.有没有解决方案的人.
| 归档时间: |
|
| 查看次数: |
12239 次 |
| 最近记录: |