当我尝试从我的模拟器运行内置相机应用程序时,我收到消息:“无法插入未插入SD卡的照片”。
我用作模拟器Nexus 5 API 21 x86 。我检查了AVD管理器,模拟器的SD卡设置为:.android \ avd \ Nexus_5_API_21_x86.avd \ sdcard.img,所以我猜这意味着它已启用
我不明白:
1。如果我的虚拟SD卡设置正确,为什么我会收到此消息
2. 为什么相机必须连接到SD卡?在我个人真正的Android设备中,即使我根本没有SD卡,我也在使用相机。它只是将照片存储到设备的内部存储中。
在我开发的应用程序中 3。,作为另一种可能的解决方案,我正在调用相机并提供内部存储的文件路径,但我仍然收到有关SD的相同消息卡。
我的代码:
int REQUEST_TAKE_PHOTO = 1;
public void takePicture(View view){
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 = File.createTempFile(
"blabla", /* prefix */
".jpg", /* suffix */
getFilesDir() /* directory */
);
} catch (IOException ex) {
// Error occurred while creating the File
throw new RuntimeException("Couldn't take picture");
}
// Continue only if the File was successfully created
if (photoFile != null) {
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photoFile));
startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
}
}
}
答案 0 :(得分:0)
相机可能会将图像(或缓存的图像)保存在SD卡中。如果您想测试相机是否需要SD卡(通常不需要),请删除SD卡选项。否则,我认为你可以尝试通过以下方式创建新的SD卡:
Or create new image