我在其他版本的android上运行此代码没有问题,直到我收到有关Nexus Lollipop 5.1崩溃的报告。 当我在AVD上运行带有API 22的Nexus 5时,应用程序一出现就会崩溃。代码如下:
Intent takePictureIntent = new
Intent(MediaStore.ACTION_IMAGE_CAPTURE);
// Ensure that there's a camera activity to handle the intent
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = null;
try {
photoFile = createImageFile();
} catch (IOException ex) {
// Error occurred while creating the File
bPhotoStarted = false;
}
// Continue only if the File was successfully created
if (photoFile != null) {
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photoFile));
mFullUri = Uri.fromFile(photoFile);
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
}
}