【问题标题】:Select picture from gallery and exclude a particular folder从图库中选择图片并排除特定文件夹
【发布时间】:2014-09-17 11:39:12
【问题描述】:

我正在使用下面的代码从图库中选择图片 -

Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(
                        Intent.createChooser(intent, "Select Picture"),
                        SELECT_PICTURE);
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        String selectedImagePath;
        if (requestCode == SELECT_PICTURE) {
            Uri selectedImageUri = data.getData();
            selectedImagePath = getPath(selectedImageUri);
            bmp = BitmapFactory.decodeFile(selectedImagePath);
            Button btnFolderPic = (Button) findViewById(R.id.btnFolderPic);
            Drawable pickedImage = new BitmapDrawable(bmp);
            btnFolderPic.setBackgroundDrawable(pickedImage);
            btnFolderPic.setText("");

        }
    }
}

它工作正常,但现在我想排除特定文件夹中的一些图片,以便用户无法选择这些图片。我将如何实现这一目标?

【问题讨论】:

    标签: android android-layout android-gallery


    【解决方案1】:

    我该怎么做?

    构建您自己的图库 UI,使用 MediaStore 作为您的数据源,并安排过滤掉您不希望用户看到的图像。

    ACTION_GET_CONTENT 协议中没有用于此类过滤的任何内容,即使有,也不要求所有图像的ACTION_GET_CONTENT 实现都遵守该协议。

    【讨论】:

      猜你喜欢
      • 2018-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-19
      • 2019-05-10
      • 2021-10-05
      • 2014-09-03
      • 2013-03-22
      相关资源
      最近更新 更多