【发布时间】:2011-12-04 06:40:56
【问题描述】:
在我们的代码中,我们使用如下所示的 getPhoto 方法:
public void getPhoto(View view) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
captureFile = new File(getCaptureFilePath());
captureUri = Uri.fromFile(captureFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, captureUri);
startActivityForResult(intent, CAPTURE_IMAGE);
}
和onActivityResult:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.w(TAG, "Came");
if (resultCode == RESULT_OK) {
if (requestCode == CAPTURE_IMAGE) {
try {
captureFile = new File(getCaptureFilePath());
captureUri = Uri.fromFile(captureFile);
Bitmap scaledBitmap = decodeFileAndResize(captureFile);
saveResizedAndCompressedBitmap(scaledBitmap);
Bitmap rotatedBitmap = convertToRotatedBitmap(scaledBitmap);
driverPhoto.setImageBitmap(rotatedBitmap);
Log.w(TAG, "Before recycle");
if (rotatedBitmap != scaledBitmap) {
scaledBitmap.recycle();
scaledBitmap = null;
System.gc();
}
Log.w(TAG, "After recycle");
} catch (IOException e) {
BugSenseHandler.log(TAG, e);
}
}
}
}
有时,当我按下“确定”时,onActivityResult 不会被调用(Came 不会被写入)。我的代码有什么问题?
编辑:当onActivityResult 未被调用时,12-04 12:43:36.040: INFO/WindowManager(145): WIN DEATH: Window{40839990 com.skalar/com.skalar.activities.RegisterActivity paused=false} 出现在代码中。
【问题讨论】:
标签: java android camera android-camera