无法在Android上获得清晰的图像路径

时间:2020-06-15 21:16:01

标签: java android mediastore

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case REQUEST_OPEN_GALLERY:
            if (resultCode == RESULT_OK) {
                Uri imageData = data.getData();
                String imageSrc = Files.getRealPathFromURI(this, imageData);
                ((RecipeImageFragment) getSupportFragmentManager().findFragmentById(R.id.frame_container))
                        .onImageSelected(imageSrc);

                currentRecipe.setImagePath(imageSrc);
            }
    }
}

变量Intent数据似乎在磁盘上没有清晰的uri文件。 而是在其中存在“ content://com.android.externalstorage.documents/document/primary%3APictures%2Fpr_chocolate_muffins.PNG”。请提供建议,如何获得正常的尿液?

0 个答案:

没有答案