我用这个页面:http://developer.android.com/guide/topics/media/camera.htmlAndroid的 - 摄像机图像并不总是保存
要了解如何利用现有的相机应用拍照&返回结果我的应用程序。
有时图像会保存,有时候不会。我正在测试三星Galaxy Tablet(8.9)。如果我将分辨率保留在最高设置(2048x1536)&以纵向拍摄照片,则图像不会保存。如果我以横向拍摄照片,图像可以节省大部分时间。如果我将其减少到1024x768,则图像可以节省大部分时间(无论是纵向还是横向)。
寻找方向推测这一个。
private void startCameraForCapture() {
// create Intent to take a picture and return control to the calling application
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
try {
fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE, getApplicationContext()); // create a file to save the image
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
} catch (Exception e) {
// TODO Auto-generated catch block
_errorMessageTitle = "Error 'StartCamera'";
_errorMessage = "Error: " + e.toString();
showDialog(DIALOG_ERROR_GENERAL);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
showPhoto(2);
} else if (resultCode == RESULT_CANCELED) {
// User cancelled the image capture
} else {
// Image capture failed, advise user
_errorMessageTitle = "Error in 'Take Photo'";
_errorMessage = "Image Capture Failed";
showDialog(DIALOG_NOTICE_GENERAL);
}
}
if (requestCode == CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Toast.makeText(getApplicationContext(), "Video not yet supported", Toast.LENGTH_LONG).show();
// Video captured and saved to fileUri specified in the Intent
} else if (resultCode == RESULT_CANCELED) {
// User cancelled the video capture
} else {
// Video capture failed, advise user
}
}
}
模拟器上的足够空间与您的工作或设备? – 2012-02-16 16:37:37
这是一款全新的平板电脑。我有12 GB的存储空间。当我检查RAM时,我有200 MB的空闲空间。 – Chris 2012-02-16 17:41:40
当拍照速度过快时,我们遇到了同样的问题。在下一张照片拍摄完成之前,它们并不总是保存到磁盘上,或者完全没有损坏的照片。你保存图片,然后等待?还是一个接一个呢? – 2012-02-16 22:17:18