【问题标题】:How to acess images and videos from android SD Card and internal storage如何从 Android SD 卡和内部存储访问图像和视频
【发布时间】:2012-05-15 17:30:41
【问题描述】:

我正在使用以下意图启动仅访问要在我的 Android 应用程序中使用的图像和视频的意图,如下所示。

    public static final int IMAGE_PICK = 1;
    Intent intent = new Intent();
    intent.setType("*/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent,"Select Any"), IMAGE_PICK);

使用上述内容,我可以在 IO 文件管理器和图库中看到图像,除此之外,我还可以看到联系人 API。但在这里我不想显示联系人 API。任何建议。

谢谢&问候, 文卡特。

【问题讨论】:

    标签: android


    【解决方案1】:
      public static final int IMAGE_PICK = 1;
        Intent intent = new Intent();
        intent.setType("image/*");
        intent.setType("video/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(Intent.createChooser(intent,"Select Any"), IMAGE_PICK);
    

    尝试使用此代码打开仅包含图像和视频的图库。

    参考这个LINK

    【讨论】:

    • 非常感谢。工作正常。
    • 我发现(不出所料)多次调用具有不同 mime 类型的 setType 只会设置最后一个类型(在本例中为视频)。对我有用的是一个用逗号分隔 mime 类型的调用,例如setType("图片/*, 视频/*");
    • 这个答案不起作用。正如@aaronmarino 指出的那样,文档很清楚,每次调用 setType() 都会清除以前的调用。
    猜你喜欢
    • 2015-08-30
    • 2012-03-08
    • 1970-01-01
    • 1970-01-01
    • 2015-02-20
    • 2014-11-20
    • 1970-01-01
    • 1970-01-01
    • 2021-08-23
    相关资源
    最近更新 更多