1
當我嘗試從我的模擬器運行內置攝像頭應用程序時,我收到消息:'沒有插入SD卡就無法拍照'。我正在使用仿真器Nexus 5 API 21 x86。我檢查了AVD管理器和模擬器的SD卡設置一起工作:.android \ AVD \ Nexus_5_API_21_x86.avd \ sdcard.img,所以我想這意味着它的啓用不能在模擬器中使用攝像頭 - SD卡不可用
我不明白:
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);
}
}
}
您的建議創建新的SD卡工作!謝謝。你是什麼意思:「...刪除SDCard選項。」 ? – GyRo 2015-02-11 21:13:23
我的意思是,如果您想測試CAMERA是否需要SD卡,您可以取出SD卡並重新運行。 – 2015-02-11 21:29:32