【问题标题】:Java android pick a photo from gallery for a folderJava android从图库中为文件夹选择照片
【发布时间】:2016-11-24 13:12:10
【问题描述】:

我不知道如何从一个文件夹中的图库中挑选一张照片:

现在我有了这个:

   private void galleryIntent() {
        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);//
        startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE);
}

但现在我可以从所有图库中选择一张照片,我想从文件夹 Test 中选择一张照片

【问题讨论】:

    标签: java android android-gallery android-photos android-intent-chooser


    【解决方案1】:

    将某种选择器集成到您自己的应用中,例如可能是one of these file/directory chooser libraries,并删除ACTION_GET_CONTENT

    【讨论】:

      【解决方案2】:

      试试

      private void galleryIntent() {
              Intent intent = new Intent();
              //Write your path here
              Uri uri=Uri.parse(Environment.getDownloadCacheDirectory().getPath().toString());
              intent.setDataAndType(uri, "image/*");
              intent.setAction(Intent.ACTION_GET_CONTENT);//
              startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE);
      }
      

      【讨论】:

        【解决方案3】:

        您可以考虑检查此答案。看起来很有希望。但是,如果您没有安装文件管理器,它似乎不起作用。

        https://stackoverflow.com/a/17173655/1987045

        【讨论】:

          猜你喜欢
          • 2020-10-02
          • 1970-01-01
          • 2021-05-10
          • 1970-01-01
          • 2016-02-13
          • 2014-09-03
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多