/** * 獲取圖片原圖 */ protected void getImageFromCamera() { String state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_MOUNTED)) { Intent getImageByCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); StringBuilder pathBuilder = new StringBuilder(); String out_file_path = Environment.getExternalStorageDirectory().getPath(); //路徑 pathBuilder.append(out_file_path).append(File.separator).append("Test").append(File.separator); //文件名 pathBuilder.append("temps.jpg"); uploadPhotPath = pathBuilder.toString(); File filePath = new File(uploadPhotPath); if (!filePath.getParentFile().exists()) { filePath.getParentFile().mkdirs(); } getImageByCamera.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(filePath)); getImageByCamera.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); startActivityForResult(getImageByCamera, CAPTURE_CODE); } else { Toast.makeText(getApplicationContext(), "請確認已經插入SD卡", Toast.LENGTH_LONG).show(); } }