【问题标题】:select multiple images from gallery and get all the images from onActivity result in android从图库中选择多个图像并从onActivity结果中获取所有图像在android中
【发布时间】:2015-03-23 09:17:44
【问题描述】:

在我的应用程序中,我试图从图库中选择多个图像,并且我想移动到我的文件夹。

我尝试了一些示例编码,但它无法正常工作。

我使用 android 代码来选择多个图像,但如何在 onActivity 结果中获取所有图像。

我已经试过了

  Intent intent = new Intent();
  intent.setType("image/*");
  intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
  intent.setAction(Intent.ACTION_GET_CONTENT);
  startActivityForResult(Intent.createChooser(intent,"Select Picture"), 1);

如何在 OnActivity Result 中选择这些图片

然后我也尝试了this link,但它没有显示画廊中的所有图像,并且在移动后它没有更新画廊

【问题讨论】:

标签: android-imageview android-gridview android-gallery


【解决方案1】:

希望下面的链接对你有帮助

click here

【讨论】:

  • 它没有显示画廊中的所有图片,我已经尝试过了
【解决方案2】:

要从图库中检索所有图像,请尝试使用 MergeCursor,http://developer.android.com/reference/android/database/MergeCursor.html

使用两个游标,一个从 EXTERNAL_CONTENT_URI 检索图像元数据,另一个从 INTERNAL_CONTENT_URI 检索图像元数据,如下所示:

Cursor cursor1 = this.context.getContentResolver().query(
            MediaStore.Images.Media.INTERNAL_CONTENT_URI, null, null, null, null);
Cursor cursor2 = this.context.getContentResolver().query(
            MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null, null, null);
MergeCursor cursor = new MergeCursor(new Cursor[]{ cursor1, cursor2 });

在此处引用此代码 - https://github.com/ayanami/android-sample/blob/master/image-select-sample/src/com/example/hoge/ImageMediaManager.java

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多