Javascript cordova插件照相机:如何打开特定文件夹中的图像,而不是显示图库中的所有图像

Javascript cordova插件照相机:如何打开特定文件夹中的图像,而不是显示图库中的所有图像,javascript,android,cordova,android-gallery,photo-gallery,Javascript,Android,Cordova,Android Gallery,Photo Gallery,我需要打开gallery在我的android应用程序中选择图像。这是我的代码,它工作得很好 但通过使用PHOTOLIBRARY,它将从设备的照片库中打开图像,通过使用SAVEDPHOTOALBUM,它将仅从设备的相机相册中选择图像-正如我在这里看到的那样 我想打开我的应用程序特定文件夹,而不是gallery文件夹(例如:我创建了一个名为“MYAPPIMAGES”的文件夹,其中包含我的应用程序中的图像,我只想显示“MYAPPIMAGES”文件夹中的图像,而不是gallery中的所有图像)。我如何实

我需要打开gallery在我的android应用程序中选择图像。这是我的代码,它工作得很好

但通过使用PHOTOLIBRARY,它将从设备的照片库中打开图像,通过使用SAVEDPHOTOALBUM,它将仅从设备的相机相册中选择图像-正如我在这里看到的那样

我想打开我的应用程序特定文件夹,而不是gallery文件夹(例如:我创建了一个名为“MYAPPIMAGES”的文件夹,其中包含我的应用程序中的图像,我只想显示“MYAPPIMAGES”文件夹中的图像,而不是gallery中的所有图像)。我如何实现这种行为?有机会这样做吗?提前谢谢

var picOptions = {
        destinationType: navigator.camera.DestinationType.FILE_URI,
        quality: 80,
        targetWidth: 800,
        targetHeight: 800,
        maximumImagesCount: 5,
        sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY 
    };

    $cordovaImagePicker.getPictures(picOptions).then(function (imageURI) {

        for (var i = 0; i < imageURI.length; i++) {
            var str = imageURI[i];
            var n = str.lastIndexOf('/');
            var splitStr = str.substring(n+1);
            var dir = str.substring(0,n+1);
            console.log(imageURI[i]+' '+splitStr+' '+dir);
            convert64(imageURI[i], splitStr, dir); 

        }
var picOptions={
destinationType:navigator.camera.destinationType.FILE\u URI,
质量:80,
目标宽度:800,
目标:800,
最大图像:5,
sourceType:navigator.camera.PictureSourceType.PHOTOLIBRARY
};
$cordovaImagePicker.getPictures(picOptions)。然后(函数(imageURI){
对于(var i=0;i
该选项中允许的唯一值为:

Camera.PictureSourceType:枚举 定义Camera.getPicture调用的输出格式。注意:在通过PictureSourceType.PHOTOLIBRARY或PictureSourceType.SAVEDPHOTOALBUM以及DestinationType.NATIVE_的iOS上,URI将由于特定于实现而禁用任何图像修改(调整大小、质量更改、裁剪等)

种类:照相机的静态枚举属性 性质

Name            Type    Default Description
PHOTOLIBRARY    number  0       Choose image from the device's photo library (same as SAVEDPHOTOALBUM for Android)

CAMERA          number  1       Take picture from camera

SAVEDPHOTOALBUM number  2       Choose image only from the device's Camera Roll album (same as PHOTOLIBRARY for Android)

这也可以解决您的问题,如果您在gallery中的图像没有显示,他们可能会在midle中显示404类型的位图。 请将“我的代码”中的所有标记与您的图像一起添加,因为必须有一些元数据才能在库中显示图像。 注: 这对Android 9及以下版本有效,对于Android Q,您可以将此标记与Android Q一起使用,将img存储在gallery values.put(MediaStore.Images.Media.RELATIVE_PATH,“yourFoldername”)中的特定文件夹中


谢谢你的回答,米克尔。是的,我已经读过了。但我想知道,是否有机会只打开图库中的特定文件夹,如“instagram”文件夹,而不是所有照片库或所有相机相册。我一直坚持这样做,因为只提供了3个选项。很抱歉,延迟了,我认为instagram应用程序上可以看到,它已经打开了它有自己的界面,我认为用户可以读取所有包含任何图像的dir,然后可以通过以下方式显示列出的照片:
      String resultPath = getExternalFilesDir(Environment.DIRECTORY_PICTURES)+ 
      getString(R.string.directory) + System.currentTimeMillis() + ".jpg";

       new File(resultPath).getParentFile().mkdir();

        try {
            OutputStream fileOutputStream = new FileOutputStream(resultPath);
            savedBitmap.compress(CompressFormat.JPEG, 100, fileOutputStream);
            fileOutputStream.flush();
            fileOutputStream.close();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
        savedBitmap.recycle();

        File file = new File(resultPath);
        ContentValues values = new ContentValues();
        values.put(MediaStore.Images.Media.TITLE, "Photo");
        values.put(MediaStore.Images.Media.DESCRIPTION, "Edited");
        values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
        values.put(MediaStore.Images.Media.DATE_TAKEN, System.currentTimeMillis ());
        values.put(MediaStore.Images.Media.DATE_ADDED, System.currentTimeMillis());
        values.put(MediaStore.Images.ImageColumns.BUCKET_ID, file.toString().toLowerCase(Locale.US).hashCode());
        values.put(MediaStore.Images.ImageColumns.BUCKET_DISPLAY_NAME, file.getName().toLowerCase(Locale.US));
        values.put("_data", resultPath);

        ContentResolver cr = getContentResolver();
        cr.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);




        return  resultPath;