Java 在模拟genymotion中保存相机图片不起作用

Java 在模拟genymotion中保存相机图片不起作用,java,android,android-studio,genymotion,Java,Android,Android Studio,Genymotion,我无法使用Genymotion emulator在SD卡中保存图片 用于为图像创建文件的代码 private File createImageFile() throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_"

我无法使用Genymotion emulator在SD卡中保存图片

用于为图像创建文件的代码

private File createImageFile() throws IOException {
    // Create an image file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    String imageFileName = "JPEG_" + timeStamp + "_";
    //File storageDir = Environment.getExternalStoragePublicDirectory(
    //Environment.DIRECTORY_PICTURES);
    File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
    File image = File.createTempFile(
                imageFileName,  /* prefix */
                ".jpg",         /* suffix */
                storageDir      /* directory */
        );
        mCurrentPhotoPath = "file:" + image.getAbsolutePath();

    // Save a file: path for use with ACTION_VIEW intents

    Toast.makeText(AddPhotoActivity.this, mCurrentPhotoPath + "file", Toast.LENGTH_SHORT).show();
    return image;
}

上述函数不返回任何内容。下面的功能用于启动相机意图并单击图片

private void dispatchTakePictureIntent() {
   // Toast.makeText(AddPhotoActivity.this, "Hello", Toast.LENGTH_SHORT).show();

    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
        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                    Uri.fromFile(photoFile));
            startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
        }
    }
}
我想问题出在File.createTempFile()函数中