【发布时间】: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