我已经编写了以下代码来使用移动设备中的内置摄像头捕获图像,但它提供了 0 kb 图像..plz 帮助
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File sampleDir = Environment.getExternalStorageDirectory();
try {
pic = File.createTempFile("customr", ".jpg", sampleDir);
} catch (IOException e) {
Log.e("error", "sdcard access error");
return;
}
// create a file to save the image
intent.putExtra(MediaStore.EXTRA_OUTPUT, pic.getName()); // set the image file name
// start the image capture Intent
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}