【问题标题】:Implicit Intent not showing Gallery in Android Lollipop隐式意图未在 Android Lollipop 中显示图库
【发布时间】:2016-12-22 11:53:09
【问题描述】:

开发一个社交应用程序,对于个人资料图片,我想给用户两个选项,要么他从图库中选择图像要么拍照,为此我使用 Implicit Intent 。

代码:

                   Intent intent = new Intent (Intent.ACTION_GET_CONTENT);
                intent.addCategory (Intent.CATEGORY_OPENABLE);
                intent.setType ("image/jpeg");

                Intent takePhotoIntent = new Intent (MediaStore.ACTION_IMAGE_CAPTURE);

                String pickTitle = "Select or take a new Picture"; // Or get from strings.xml
                Intent chooserIntent = Intent.createChooser (intent, pickTitle);
                chooserIntent.putExtra
                        (
                                Intent.EXTRA_INITIAL_INTENTS,
                                new Intent[]{takePhotoIntent}
                        );

                startActivityForResult (chooserIntent, GALLERY_KITKAT_INTENT_CALLED);
            }

但 Intent 仅显示 Document + Camera

没有画廊

这个意图有什么问题,为什么它不显示 Gallery ?

测试设备:Android Lollipop

【问题讨论】:

  • 你可以使用集合类型作为intent.setType("/"); .. 这可能会有所帮助
  • @Riten 这有什么帮助,我想可能没有
  • 你能用“image/*”试试吗?还有什么你打开你选择图标所有文档或只是图像?
  • @petrumo 只是图片
  • @AndroidMan 你知道为什么会这样吗?

标签: android android-intent mobile


【解决方案1】:

显示的内容没有任何问题。

您有两个选项ACTION_GET_CONTENTACTION_IMAGE_CAPTURE,您可以通过Documents or Camera 进行选择。

如果您选择Documents,您将获得ACTION_GET_CONTENT 的正常选择器。

之后您可以选择“画廊”。

【讨论】:

  • @greenapp 我想在 Document 的地方展示画廊
猜你喜欢
  • 1970-01-01
  • 2014-12-15
  • 1970-01-01
  • 2015-03-14
  • 2016-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多