使用 android 中的 MultipleImageSelect 库从图库中获取所选图像的路径

get path of selected images from gallery using MultipleImageSelect library in android

在我的项目中,我需要一种方法来获取从图库中选择的多个图像的路径。 我正在使用这个库 MultipleSelectImages

它显​​然工作正常,但在 onActivityResult 中我需要包含每个图像路径的数组,但是我得到的结果是这样的:

Paths: [com.darsh.multipleimageselect.models.Image@1e6d3057, com.darsh.multipleimageselect.models.Image@33824744]

...当我需要真实路径时 (/storage/emulated/0/DCIM/Camera/20150426_110936.jpg)

阅读库文档未找到解决方案。

这是 onActivityResult 方法:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == Constants.REQUEST_CODE && resultCode == RESULT_OK && data != null) {
        //The array list has the image paths of the selected images
        ArrayList<Image> images = data.getParcelableArrayListExtra(Constants.INTENT_EXTRA_IMAGES);

        Log.i("myLogs", "Paths:" + " " + images);
    }
}

...其中 "image" 它是从库中导入的

import com.darsh.multipleimageselect.models.Image;

我没有使用 EXTRA_ALLOW_MULTIPLE 因为需要该应用程序在 android api 16 版本

中运行

在此先致谢。

尝试使用下面的代码;

onActivityResult();-

            Uri selectedImage = data.getData();
            String[] filePathColumn = { MediaStore.Images.Media.DATA };


            Cursor cursor = getContentResolver().query(selectedImage,
                    filePathColumn, null, null, null);

            cursor.moveToFirst();

            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
            String imgPath = cursor.getString(columnIndex);
            cursor.close();