我正在做一个相机应用程序,它从相机中挑选照片我正在使用以下代码,它在三星 Galaxy ace 中工作,但在带有 Android OS 2.2 的 Htc Desire 中它不起作用,请帮助我解决它,提前致谢。
**capture button Onclick:**
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
String fileName = "IMG_" + simpleDateFormat.format(new Date()) + ".jpg";
File myDirectory = new File(Environment.getExternalStorageDirectory() + "/DCIM/Camera/");
cameraImageFile = new File(myDirectory, fileName);
Uri imageUri = Uri.fromFile(cameraImageFile);
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, CAMERA_PIC_REQUEST);
**OnActivityResult:**
switch (requestCode) {
case CAMERA_PIC_REQUEST:
ImageView.setImageBitmap(decodeFile(cameraImageFile.getAbsolutePath()));
}
break;